babylon.d.ts 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. /**
  78. * Effect layers to keep.
  79. */
  80. effectLayers: EffectLayer[];
  81. }
  82. /**
  83. * Container with a set of assets that can be added or removed from a scene.
  84. */
  85. class AssetContainer {
  86. /**
  87. * The scene the AssetContainer belongs to.
  88. */
  89. scene: Scene;
  90. /**
  91. * Cameras populated in the container.
  92. */
  93. cameras: Camera[];
  94. /**
  95. * Lights populated in the container.
  96. */
  97. lights: Light[];
  98. /**
  99. * Meshes populated in the container.
  100. */
  101. meshes: AbstractMesh[];
  102. /**
  103. * Skeletons populated in the container.
  104. */
  105. skeletons: Skeleton[];
  106. /**
  107. * ParticleSystems populated in the container.
  108. */
  109. particleSystems: IParticleSystem[];
  110. /**
  111. * Animations populated in the container.
  112. */
  113. animations: Animation[];
  114. /**
  115. * AnimationGroups populated in the container.
  116. */
  117. animationGroups: AnimationGroup[];
  118. /**
  119. * MultiMaterials populated in the container.
  120. */
  121. multiMaterials: MultiMaterial[];
  122. /**
  123. * Materials populated in the container.
  124. */
  125. materials: Material[];
  126. /**
  127. * MorphTargetManagers populated in the container.
  128. */
  129. morphTargetManagers: MorphTargetManager[];
  130. /**
  131. * Geometries populated in the container.
  132. */
  133. geometries: Geometry[];
  134. /**
  135. * TransformNodes populated in the container.
  136. */
  137. transformNodes: TransformNode[];
  138. /**
  139. * LensFlareSystems populated in the container.
  140. */
  141. lensFlareSystems: LensFlareSystem[];
  142. /**
  143. * ShadowGenerators populated in the container.
  144. */
  145. shadowGenerators: ShadowGenerator[];
  146. /**
  147. * ActionManagers populated in the container.
  148. */
  149. actionManagers: ActionManager[];
  150. /**
  151. * Sounds populated in the container.
  152. */
  153. sounds: Sound[];
  154. /**
  155. * Textures populated in the container.
  156. */
  157. textures: Texture[];
  158. /**
  159. * Effect layers populated in the container.
  160. */
  161. effectLayers: EffectLayer[];
  162. /**
  163. * Instantiates an AssetContainer.
  164. * @param scene The scene the AssetContainer belongs to.
  165. */
  166. constructor(scene: Scene);
  167. /**
  168. * Adds all the assets from the container to the scene.
  169. */
  170. addAllToScene(): void;
  171. /**
  172. * Removes all the assets in the container from the scene
  173. */
  174. removeAllFromScene(): void;
  175. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  176. /**
  177. * Removes all the assets contained in the scene and adds them to the container.
  178. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  179. */
  180. moveAllFromScene(keepAssets?: KeepAssets): void;
  181. /**
  182. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  183. * @returns the root mesh
  184. */
  185. createRootMesh(): Mesh;
  186. }
  187. }
  188. interface Window {
  189. mozIndexedDB: IDBFactory;
  190. webkitIndexedDB: IDBFactory;
  191. msIndexedDB: IDBFactory;
  192. webkitURL: typeof URL;
  193. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  194. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  195. WebGLRenderingContext: WebGLRenderingContext;
  196. MSGesture: MSGesture;
  197. CANNON: any;
  198. AudioContext: AudioContext;
  199. webkitAudioContext: AudioContext;
  200. PointerEvent: any;
  201. Math: Math;
  202. Uint8Array: Uint8ArrayConstructor;
  203. Float32Array: Float32ArrayConstructor;
  204. mozURL: typeof URL;
  205. msURL: typeof URL;
  206. VRFrameData: any;
  207. DracoDecoderModule: any;
  208. }
  209. interface WebGLRenderingContext {
  210. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  211. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  212. vertexAttribDivisor(index: number, divisor: number): void;
  213. createVertexArray(): any;
  214. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  215. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  216. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  217. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  218. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  219. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  220. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  221. createQuery(): WebGLQuery;
  222. deleteQuery(query: WebGLQuery): void;
  223. beginQuery(target: number, query: WebGLQuery): void;
  224. endQuery(target: number): void;
  225. getQueryParameter(query: WebGLQuery, pname: number): any;
  226. getQuery(target: number, pname: number): any;
  227. MAX_SAMPLES: number;
  228. RGBA8: number;
  229. READ_FRAMEBUFFER: number;
  230. DRAW_FRAMEBUFFER: number;
  231. UNIFORM_BUFFER: number;
  232. HALF_FLOAT_OES: number;
  233. RGBA16F: number;
  234. RGBA32F: number;
  235. R32F: number;
  236. RG32F: number;
  237. RGB32F: number;
  238. R16F: number;
  239. RG16F: number;
  240. RGB16F: number;
  241. RED: number;
  242. RG: number;
  243. R8: number;
  244. RG8: number;
  245. UNSIGNED_INT_24_8: number;
  246. DEPTH24_STENCIL8: number;
  247. drawBuffers(buffers: number[]): void;
  248. readBuffer(src: number): void;
  249. readonly COLOR_ATTACHMENT0: number;
  250. readonly COLOR_ATTACHMENT1: number;
  251. readonly COLOR_ATTACHMENT2: number;
  252. readonly COLOR_ATTACHMENT3: number;
  253. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  254. ANY_SAMPLES_PASSED: number;
  255. QUERY_RESULT_AVAILABLE: number;
  256. QUERY_RESULT: number;
  257. }
  258. interface Document {
  259. mozCancelFullScreen(): void;
  260. msCancelFullScreen(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. fullscreen: boolean;
  264. mozPointerLockElement: HTMLElement;
  265. msPointerLockElement: HTMLElement;
  266. webkitPointerLockElement: HTMLElement;
  267. }
  268. interface HTMLCanvasElement {
  269. msRequestPointerLock?(): void;
  270. mozRequestPointerLock?(): void;
  271. webkitRequestPointerLock?(): void;
  272. }
  273. interface CanvasRenderingContext2D {
  274. msImageSmoothingEnabled: boolean;
  275. }
  276. interface WebGLBuffer {
  277. references: number;
  278. capacity: number;
  279. is32Bits: boolean;
  280. }
  281. interface WebGLProgram {
  282. transformFeedback?: WebGLTransformFeedback | null;
  283. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  284. }
  285. interface MouseEvent {
  286. mozMovementX: number;
  287. mozMovementY: number;
  288. webkitMovementX: number;
  289. webkitMovementY: number;
  290. msMovementX: number;
  291. msMovementY: number;
  292. }
  293. interface Navigator {
  294. mozGetVRDevices: (any: any) => any;
  295. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  296. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  297. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. webkitGetGamepads(): Gamepad[];
  299. msGetGamepads(): Gamepad[];
  300. webkitGamepads(): Gamepad[];
  301. }
  302. interface HTMLVideoElement {
  303. mozSrcObject: any;
  304. }
  305. interface Screen {
  306. orientation: string;
  307. mozOrientation: string;
  308. }
  309. interface Math {
  310. fround(x: number): number;
  311. imul(a: number, b: number): number;
  312. }
  313. interface EXT_disjoint_timer_query {
  314. QUERY_COUNTER_BITS_EXT: number;
  315. TIME_ELAPSED_EXT: number;
  316. TIMESTAMP_EXT: number;
  317. GPU_DISJOINT_EXT: number;
  318. QUERY_RESULT_EXT: number;
  319. QUERY_RESULT_AVAILABLE_EXT: number;
  320. queryCounterEXT(query: WebGLQuery, target: number): void;
  321. createQueryEXT(): WebGLQuery;
  322. beginQueryEXT(target: number, query: WebGLQuery): void;
  323. endQueryEXT(target: number): void;
  324. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  325. deleteQueryEXT(query: WebGLQuery): void;
  326. }
  327. interface WebGLUniformLocation {
  328. _currentState: any;
  329. }
  330. declare module BABYLON {
  331. /**
  332. * Node is the basic class for all scene objects (Mesh, Light Camera).
  333. */
  334. class Node implements IBehaviorAware<Node> {
  335. /**
  336. * Gets or sets the name of the node
  337. */
  338. name: string;
  339. /**
  340. * Gets or sets the id of the node
  341. */
  342. id: string;
  343. /**
  344. * Gets or sets the unique id of the node
  345. */
  346. uniqueId: number;
  347. /**
  348. * Gets or sets a string used to store user defined state for the node
  349. */
  350. state: string;
  351. /**
  352. * Gets or sets an object used to store user defined information for the node
  353. */
  354. metadata: any;
  355. /**
  356. * Gets or sets a boolean used to define if the node must be serialized
  357. */
  358. doNotSerialize: boolean;
  359. /** @hidden */
  360. _isDisposed: boolean;
  361. /**
  362. * Gets a list of Animations associated with the node
  363. */
  364. animations: Animation[];
  365. private _ranges;
  366. /**
  367. * Callback raised when the node is ready to be used
  368. */
  369. onReady: (node: Node) => void;
  370. private _isEnabled;
  371. private _isReady;
  372. /** @hidden */
  373. _currentRenderId: number;
  374. private _parentRenderId;
  375. protected _childRenderId: number;
  376. /** @hidden */
  377. _waitingParentId: Nullable<string>;
  378. private _scene;
  379. /** @hidden */
  380. _cache: any;
  381. private _parentNode;
  382. private _children;
  383. /**
  384. * Gets a boolean indicating if the node has been disposed
  385. * @returns true if the node was disposed
  386. */
  387. isDisposed(): boolean;
  388. /**
  389. * Gets or sets the parent of the node
  390. */
  391. parent: Nullable<Node>;
  392. private _animationPropertiesOverride;
  393. /**
  394. * Gets or sets the animation properties override
  395. */
  396. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  397. /**
  398. * Gets a string idenfifying the name of the class
  399. * @returns "Node" string
  400. */
  401. getClassName(): string;
  402. /**
  403. * An event triggered when the mesh is disposed
  404. */
  405. onDisposeObservable: Observable<Node>;
  406. private _onDisposeObserver;
  407. /**
  408. * Sets a callback that will be raised when the node will be disposed
  409. */
  410. onDispose: () => void;
  411. /**
  412. * Creates a new Node
  413. * @param {string} name - the name and id to be given to this node
  414. * @param {BABYLON.Scene} the scene this node will be added to
  415. */
  416. constructor(name: string, scene?: Nullable<Scene>);
  417. /**
  418. * Gets the scene of the node
  419. * @returns a {BABYLON.Scene}
  420. */
  421. getScene(): Scene;
  422. /**
  423. * Gets the engine of the node
  424. * @returns a {BABYLON.Engine}
  425. */
  426. getEngine(): Engine;
  427. private _behaviors;
  428. /**
  429. * Attach a behavior to the node
  430. * @see http://doc.babylonjs.com/features/behaviour
  431. * @param behavior defines the behavior to attach
  432. * @returns the current Node
  433. */
  434. addBehavior(behavior: Behavior<Node>): Node;
  435. /**
  436. * Remove an attached behavior
  437. * @see http://doc.babylonjs.com/features/behaviour
  438. * @param behavior defines the behavior to attach
  439. * @returns the current Node
  440. */
  441. removeBehavior(behavior: Behavior<Node>): Node;
  442. /**
  443. * Gets the list of attached behaviors
  444. * @see http://doc.babylonjs.com/features/behaviour
  445. */
  446. readonly behaviors: Behavior<Node>[];
  447. /**
  448. * Gets an attached behavior by name
  449. * @param name defines the name of the behavior to look for
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. * @returns null if behavior was not found else the requested behavior
  452. */
  453. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  454. /**
  455. * Returns the world matrix of the node
  456. * @returns a matrix containing the node's world matrix
  457. */
  458. getWorldMatrix(): Matrix;
  459. /** @hidden */
  460. _getWorldMatrixDeterminant(): number;
  461. /** @hidden */
  462. _initCache(): void;
  463. /** @hidden */
  464. updateCache(force?: boolean): void;
  465. /** @hidden */
  466. _updateCache(ignoreParentClass?: boolean): void;
  467. /** @hidden */
  468. _isSynchronized(): boolean;
  469. /** @hidden */
  470. _markSyncedWithParent(): void;
  471. /** @hidden */
  472. isSynchronizedWithParent(): boolean;
  473. /** @hidden */
  474. isSynchronized(updateCache?: boolean): boolean;
  475. /** @hidden */
  476. hasNewParent(update?: boolean): boolean;
  477. /**
  478. * Is this node ready to be used/rendered
  479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  480. * @return true if the node is ready
  481. */
  482. isReady(completeCheck?: boolean): boolean;
  483. /**
  484. * Is this node enabled?
  485. * 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
  486. * @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
  487. * @return whether this node (and its parent) is enabled
  488. */
  489. isEnabled(checkAncestors?: boolean): boolean;
  490. /**
  491. * Set the enabled state of this node
  492. * @param value defines the new enabled state
  493. */
  494. setEnabled(value: boolean): void;
  495. /**
  496. * Is this node a descendant of the given node?
  497. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  498. * @param ancestor defines the parent node to inspect
  499. * @returns a boolean indicating if this node is a descendant of the given node
  500. */
  501. isDescendantOf(ancestor: Node): boolean;
  502. /** @hidden */
  503. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  504. /**
  505. * Will return all nodes that have this node as ascendant
  506. * @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
  507. * @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
  508. * @return all children nodes of all types
  509. */
  510. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  511. /**
  512. * Get all child-meshes of this node
  513. * @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
  514. * @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
  515. * @returns an array of {BABYLON.AbstractMesh}
  516. */
  517. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  518. /**
  519. * Get all child-transformNodes of this node
  520. * @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
  521. * @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
  522. * @returns an array of {BABYLON.TransformNode}
  523. */
  524. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  525. /**
  526. * Get all direct children of this node
  527. * @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
  528. * @returns an array of {BABYLON.Node}
  529. */
  530. getChildren(predicate?: (node: Node) => boolean): Node[];
  531. /** @hidden */
  532. _setReady(state: boolean): void;
  533. /**
  534. * Get an animation by name
  535. * @param name defines the name of the animation to look for
  536. * @returns null if not found else the requested animation
  537. */
  538. getAnimationByName(name: string): Nullable<Animation>;
  539. /**
  540. * Creates an animation range for this node
  541. * @param name defines the name of the range
  542. * @param from defines the starting key
  543. * @param to defines the end key
  544. */
  545. createAnimationRange(name: string, from: number, to: number): void;
  546. /**
  547. * Delete a specific animation range
  548. * @param name defines the name of the range to delete
  549. * @param deleteFrames defines if animation frames from the range must be deleted as well
  550. */
  551. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  552. /**
  553. * Get an animation range by name
  554. * @param name defines the name of the animation range to look for
  555. * @returns null if not found else the requested animation range
  556. */
  557. getAnimationRange(name: string): Nullable<AnimationRange>;
  558. /**
  559. * Will start the animation sequence
  560. * @param name defines the range frames for animation sequence
  561. * @param loop defines if the animation should loop (false by default)
  562. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  563. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  564. * @returns the object created for this animation. If range does not exist, it will return null
  565. */
  566. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  567. /**
  568. * Serialize animation ranges into a JSON compatible object
  569. * @returns serialization object
  570. */
  571. serializeAnimationRanges(): any;
  572. /**
  573. * Computes the world matrix of the node
  574. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  575. * @returns the world matrix
  576. */
  577. computeWorldMatrix(force?: boolean): Matrix;
  578. /**
  579. * Releases resources associated with this node.
  580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  582. */
  583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  584. /**
  585. * Parse animation range data from a serialization object and store them into a given node
  586. * @param node defines where to store the animation ranges
  587. * @param parsedNode defines the serialization object to read data from
  588. * @param scene defines the hosting scene
  589. */
  590. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  591. }
  592. }
  593. declare module BABYLON {
  594. /**
  595. * Define an interface for all classes that will hold resources
  596. */
  597. interface IDisposable {
  598. /**
  599. * Releases all held resources
  600. */
  601. dispose(): void;
  602. }
  603. /**
  604. * Interface used to let developers provide their own mesh selection mechanism
  605. */
  606. interface IActiveMeshCandidateProvider {
  607. /**
  608. * Return the list of active meshes
  609. * @param scene defines the current scene
  610. * @returns the list of active meshes
  611. */
  612. getMeshes(scene: Scene): AbstractMesh[];
  613. /**
  614. * Indicates if the meshes have been checked to make sure they are isEnabled()
  615. */
  616. readonly checksIsEnabled: boolean;
  617. }
  618. /**
  619. * This class is used by the onRenderingGroupObservable
  620. */
  621. class RenderingGroupInfo {
  622. /**
  623. * The Scene that being rendered
  624. */
  625. scene: Scene;
  626. /**
  627. * The camera currently used for the rendering pass
  628. */
  629. camera: Nullable<Camera>;
  630. /**
  631. * The ID of the renderingGroup being processed
  632. */
  633. renderingGroupId: number;
  634. /**
  635. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  636. */
  637. renderStage: number;
  638. /**
  639. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  640. * This stage will be fired no matter what
  641. */
  642. static STAGE_PRECLEAR: number;
  643. /**
  644. * Called before opaque object are rendered.
  645. * This stage will be fired only if there's 3D Opaque content to render
  646. */
  647. static STAGE_PREOPAQUE: number;
  648. /**
  649. * Called after the opaque objects are rendered and before the transparent ones
  650. * This stage will be fired only if there's 3D transparent content to render
  651. */
  652. static STAGE_PRETRANSPARENT: number;
  653. /**
  654. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  655. * This stage will be fired no matter what
  656. */
  657. static STAGE_POSTTRANSPARENT: number;
  658. }
  659. /**
  660. * Represents a scene to be rendered by the engine.
  661. * @see http://doc.babylonjs.com/features/scene
  662. */
  663. class Scene implements IAnimatable {
  664. private static _FOGMODE_NONE;
  665. private static _FOGMODE_EXP;
  666. private static _FOGMODE_EXP2;
  667. private static _FOGMODE_LINEAR;
  668. private static _uniqueIdCounter;
  669. /**
  670. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  672. */
  673. static MinDeltaTime: number;
  674. /**
  675. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  677. */
  678. static MaxDeltaTime: number;
  679. /** The fog is deactivated */
  680. static readonly FOGMODE_NONE: number;
  681. /** The fog density is following an exponential function */
  682. static readonly FOGMODE_EXP: number;
  683. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  684. static readonly FOGMODE_EXP2: number;
  685. /** The fog density is following a linear function. */
  686. static readonly FOGMODE_LINEAR: number;
  687. /**
  688. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  689. */
  690. autoClear: boolean;
  691. /**
  692. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  693. */
  694. autoClearDepthAndStencil: boolean;
  695. /**
  696. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  697. */
  698. clearColor: Color4;
  699. /**
  700. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  701. */
  702. ambientColor: Color3;
  703. /** @hidden */
  704. _environmentBRDFTexture: BaseTexture;
  705. /** @hidden */
  706. protected _environmentTexture: BaseTexture;
  707. /**
  708. * Texture used in all pbr material as the reflection texture.
  709. * As in the majority of the scene they are the same (exception for multi room and so on),
  710. * this is easier to reference from here than from all the materials.
  711. */
  712. /**
  713. * Texture used in all pbr material as the reflection texture.
  714. * As in the majority of the scene they are the same (exception for multi room and so on),
  715. * this is easier to set here than in all the materials.
  716. */
  717. environmentTexture: BaseTexture;
  718. /** @hidden */
  719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  720. /**
  721. * Default image processing configuration used either in the rendering
  722. * Forward main pass or through the imageProcessingPostProcess if present.
  723. * As in the majority of the scene they are the same (exception for multi camera),
  724. * this is easier to reference from here than from all the materials and post process.
  725. *
  726. * No setter as we it is a shared configuration, you can set the values instead.
  727. */
  728. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  729. private _forceWireframe;
  730. /**
  731. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  732. */
  733. forceWireframe: boolean;
  734. private _forcePointsCloud;
  735. /**
  736. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  737. */
  738. forcePointsCloud: boolean;
  739. /**
  740. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  741. */
  742. forceShowBoundingBoxes: boolean;
  743. /**
  744. * Gets or sets the active clipplane
  745. */
  746. clipPlane: Nullable<Plane>;
  747. /**
  748. * Gets or sets a boolean indicating if animations are enabled
  749. */
  750. animationsEnabled: boolean;
  751. private _animationPropertiesOverride;
  752. /**
  753. * Gets or sets the animation properties override
  754. */
  755. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  756. /**
  757. * Gets or sets a boolean indicating if a constant deltatime has to be used
  758. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  759. */
  760. useConstantAnimationDeltaTime: boolean;
  761. /**
  762. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  763. * Please note that it requires to run a ray cast through the scene on every frame
  764. */
  765. constantlyUpdateMeshUnderPointer: boolean;
  766. /**
  767. * Defines the HTML cursor to use when hovering over interactive elements
  768. */
  769. hoverCursor: string;
  770. /**
  771. * Defines the HTML default cursor to use (empty by default)
  772. */
  773. defaultCursor: string;
  774. /**
  775. * This is used to call preventDefault() on pointer down
  776. * in order to block unwanted artifacts like system double clicks
  777. */
  778. preventDefaultOnPointerDown: boolean;
  779. /**
  780. * Gets or sets user defined metadata
  781. */
  782. metadata: any;
  783. /**
  784. * Gets the name of the plugin used to load this scene (null by default)
  785. */
  786. loadingPluginName: string;
  787. /**
  788. * Use this array to add regular expressions used to disable offline support for specific urls
  789. */
  790. disableOfflineSupportExceptionRules: RegExp[];
  791. private _spritePredicate;
  792. /**
  793. * An event triggered when the scene is disposed.
  794. */
  795. onDisposeObservable: Observable<Scene>;
  796. private _onDisposeObserver;
  797. /** Sets a function to be executed when this scene is disposed. */
  798. onDispose: () => void;
  799. /**
  800. * An event triggered before rendering the scene (right after animations and physics)
  801. */
  802. onBeforeRenderObservable: Observable<Scene>;
  803. private _onBeforeRenderObserver;
  804. /** Sets a function to be executed before rendering this scene */
  805. beforeRender: Nullable<() => void>;
  806. /**
  807. * An event triggered after rendering the scene
  808. */
  809. onAfterRenderObservable: Observable<Scene>;
  810. private _onAfterRenderObserver;
  811. /** Sets a function to be executed after rendering this scene */
  812. afterRender: Nullable<() => void>;
  813. /**
  814. * An event triggered before animating the scene
  815. */
  816. onBeforeAnimationsObservable: Observable<Scene>;
  817. /**
  818. * An event triggered after animations processing
  819. */
  820. onAfterAnimationsObservable: Observable<Scene>;
  821. /**
  822. * An event triggered before draw calls are ready to be sent
  823. */
  824. onBeforeDrawPhaseObservable: Observable<Scene>;
  825. /**
  826. * An event triggered after draw calls have been sent
  827. */
  828. onAfterDrawPhaseObservable: Observable<Scene>;
  829. /**
  830. * An event triggered when physic simulation is about to be run
  831. */
  832. onBeforePhysicsObservable: Observable<Scene>;
  833. /**
  834. * An event triggered when physic simulation has been done
  835. */
  836. onAfterPhysicsObservable: Observable<Scene>;
  837. /**
  838. * An event triggered when the scene is ready
  839. */
  840. onReadyObservable: Observable<Scene>;
  841. /**
  842. * An event triggered before rendering a camera
  843. */
  844. onBeforeCameraRenderObservable: Observable<Camera>;
  845. private _onBeforeCameraRenderObserver;
  846. /** Sets a function to be executed before rendering a camera*/
  847. beforeCameraRender: () => void;
  848. /**
  849. * An event triggered after rendering a camera
  850. */
  851. onAfterCameraRenderObservable: Observable<Camera>;
  852. private _onAfterCameraRenderObserver;
  853. /** Sets a function to be executed after rendering a camera*/
  854. afterCameraRender: () => void;
  855. /**
  856. * An event triggered when active meshes evaluation is about to start
  857. */
  858. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when active meshes evaluation is done
  861. */
  862. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when particles rendering is about to start
  865. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  866. */
  867. onBeforeParticlesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when particles rendering is done
  870. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  871. */
  872. onAfterParticlesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when sprites rendering is about to start
  875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  876. */
  877. onBeforeSpritesRenderingObservable: Observable<Scene>;
  878. /**
  879. * An event triggered when sprites rendering is done
  880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  881. */
  882. onAfterSpritesRenderingObservable: Observable<Scene>;
  883. /**
  884. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  885. */
  886. onDataLoadedObservable: Observable<Scene>;
  887. /**
  888. * An event triggered when a camera is created
  889. */
  890. onNewCameraAddedObservable: Observable<Camera>;
  891. /**
  892. * An event triggered when a camera is removed
  893. */
  894. onCameraRemovedObservable: Observable<Camera>;
  895. /**
  896. * An event triggered when a light is created
  897. */
  898. onNewLightAddedObservable: Observable<Light>;
  899. /**
  900. * An event triggered when a light is removed
  901. */
  902. onLightRemovedObservable: Observable<Light>;
  903. /**
  904. * An event triggered when a geometry is created
  905. */
  906. onNewGeometryAddedObservable: Observable<Geometry>;
  907. /**
  908. * An event triggered when a geometry is removed
  909. */
  910. onGeometryRemovedObservable: Observable<Geometry>;
  911. /**
  912. * An event triggered when a transform node is created
  913. */
  914. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  915. /**
  916. * An event triggered when a transform node is removed
  917. */
  918. onTransformNodeRemovedObservable: Observable<TransformNode>;
  919. /**
  920. * An event triggered when a mesh is created
  921. */
  922. onNewMeshAddedObservable: Observable<AbstractMesh>;
  923. /**
  924. * An event triggered when a mesh is removed
  925. */
  926. onMeshRemovedObservable: Observable<AbstractMesh>;
  927. /**
  928. * An event triggered when render targets are about to be rendered
  929. * Can happen multiple times per frame.
  930. */
  931. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  932. /**
  933. * An event triggered when render targets were rendered.
  934. * Can happen multiple times per frame.
  935. */
  936. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  937. /**
  938. * An event triggered before calculating deterministic simulation step
  939. */
  940. onBeforeStepObservable: Observable<Scene>;
  941. /**
  942. * An event triggered after calculating deterministic simulation step
  943. */
  944. onAfterStepObservable: Observable<Scene>;
  945. /**
  946. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  947. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  948. * 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)
  949. */
  950. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  951. /**
  952. * Gets a list of Animations associated with the scene
  953. */
  954. animations: Animation[];
  955. private _registeredForLateAnimationBindings;
  956. /**
  957. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  958. */
  959. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  960. /**
  961. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  962. */
  963. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  964. /**
  965. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  966. */
  967. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  968. private _onPointerMove;
  969. private _onPointerDown;
  970. private _onPointerUp;
  971. /** Deprecated. Use onPointerObservable instead */
  972. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  973. /** Deprecated. Use onPointerObservable instead */
  974. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  975. /** Deprecated. Use onPointerObservable instead */
  976. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  977. /** Deprecated. Use onPointerObservable instead */
  978. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  979. private _gamepadManager;
  980. /**
  981. * Gets the gamepad manager associated with the scene
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  983. */
  984. readonly gamepadManager: GamepadManager;
  985. /**
  986. * 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).
  987. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  988. */
  989. onPrePointerObservable: Observable<PointerInfoPre>;
  990. /**
  991. * Observable event triggered each time an input event is received from the rendering canvas
  992. */
  993. onPointerObservable: Observable<PointerInfo>;
  994. /**
  995. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  996. */
  997. readonly unTranslatedPointer: Vector2;
  998. /** The distance in pixel that you have to move to prevent some events */
  999. static DragMovementThreshold: number;
  1000. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1001. static LongPressDelay: number;
  1002. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1003. static DoubleClickDelay: number;
  1004. /** If you need to check double click without raising a single click at first click, enable this flag */
  1005. static ExclusiveDoubleClickMode: boolean;
  1006. private _initClickEvent;
  1007. private _initActionManager;
  1008. private _delayedSimpleClick;
  1009. private _delayedSimpleClickTimeout;
  1010. private _previousDelayedSimpleClickTimeout;
  1011. private _meshPickProceed;
  1012. private _previousButtonPressed;
  1013. private _currentPickResult;
  1014. private _previousPickResult;
  1015. private _totalPointersPressed;
  1016. private _doubleClickOccured;
  1017. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1018. cameraToUseForPointers: Nullable<Camera>;
  1019. private _pointerX;
  1020. private _pointerY;
  1021. private _unTranslatedPointerX;
  1022. private _unTranslatedPointerY;
  1023. private _startingPointerPosition;
  1024. private _previousStartingPointerPosition;
  1025. private _startingPointerTime;
  1026. private _previousStartingPointerTime;
  1027. private _pointerCaptures;
  1028. private _timeAccumulator;
  1029. private _currentStepId;
  1030. private _currentInternalStep;
  1031. /** @hidden */
  1032. _mirroredCameraPosition: Nullable<Vector3>;
  1033. /**
  1034. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1035. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1036. */
  1037. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1038. /**
  1039. * Observable event triggered each time an keyboard event is received from the hosting window
  1040. */
  1041. onKeyboardObservable: Observable<KeyboardInfo>;
  1042. private _onKeyDown;
  1043. private _onKeyUp;
  1044. private _onCanvasFocusObserver;
  1045. private _onCanvasBlurObserver;
  1046. private _useRightHandedSystem;
  1047. /**
  1048. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1049. */
  1050. useRightHandedSystem: boolean;
  1051. /**
  1052. * Sets the step Id used by deterministic lock step
  1053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1054. * @param newStepId defines the step Id
  1055. */
  1056. setStepId(newStepId: number): void;
  1057. /**
  1058. * Gets the step Id used by deterministic lock step
  1059. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1060. * @returns the step Id
  1061. */
  1062. getStepId(): number;
  1063. /**
  1064. * Gets the internal step used by deterministic lock step
  1065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1066. * @returns the internal step
  1067. */
  1068. getInternalStep(): number;
  1069. private _fogEnabled;
  1070. /**
  1071. * Gets or sets a boolean indicating if fog is enabled on this scene
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogEnabled: boolean;
  1075. private _fogMode;
  1076. /**
  1077. * Gets or sets the fog mode to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogMode: number;
  1081. /**
  1082. * Gets or sets the fog color to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogColor: Color3;
  1086. /**
  1087. * Gets or sets the fog density to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogDensity: number;
  1091. /**
  1092. * Gets or sets the fog start distance to use
  1093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1094. */
  1095. fogStart: number;
  1096. /**
  1097. * Gets or sets the fog end distance to use
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. */
  1100. fogEnd: number;
  1101. private _shadowsEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1104. */
  1105. shadowsEnabled: boolean;
  1106. private _lightsEnabled;
  1107. /**
  1108. * Gets or sets a boolean indicating if lights are enabled on this scene
  1109. */
  1110. lightsEnabled: boolean;
  1111. /**
  1112. * All of the lights added to this scene
  1113. * @see http://doc.babylonjs.com/babylon101/lights
  1114. */
  1115. lights: Light[];
  1116. /** All of the cameras added to this scene.
  1117. * @see http://doc.babylonjs.com/babylon101/cameras
  1118. */
  1119. cameras: Camera[];
  1120. /** All of the active cameras added to this scene. */
  1121. activeCameras: Camera[];
  1122. /** The current active camera */
  1123. activeCamera: Nullable<Camera>;
  1124. /**
  1125. * All of the tranform nodes added to this scene
  1126. * @see http://doc.babylonjs.com/how_to/transformnode
  1127. */
  1128. transformNodes: TransformNode[];
  1129. /**
  1130. * All of the (abstract) meshes added to this scene
  1131. */
  1132. meshes: AbstractMesh[];
  1133. /**
  1134. * All of the animation groups added to this scene
  1135. * @see http://doc.babylonjs.com/how_to/group
  1136. */
  1137. animationGroups: AnimationGroup[];
  1138. private _geometries;
  1139. /**
  1140. * All of the materials added to this scene
  1141. * @see http://doc.babylonjs.com/babylon101/materials
  1142. */
  1143. materials: Material[];
  1144. /**
  1145. * All of the multi-materials added to this scene
  1146. * @see http://doc.babylonjs.com/how_to/multi_materials
  1147. */
  1148. multiMaterials: MultiMaterial[];
  1149. private _defaultMaterial;
  1150. /** The default material used on meshes when no material is affected */
  1151. /** The default material used on meshes when no material is affected */
  1152. defaultMaterial: Material;
  1153. private _texturesEnabled;
  1154. /**
  1155. * Gets or sets a boolean indicating if textures are enabled on this scene
  1156. */
  1157. texturesEnabled: boolean;
  1158. /**
  1159. * All of the textures added to this scene
  1160. */
  1161. textures: BaseTexture[];
  1162. /**
  1163. * Gets or sets a boolean indicating if particles are enabled on this scene
  1164. */
  1165. particlesEnabled: boolean;
  1166. /**
  1167. * All of the particle systems added to this scene
  1168. * @see http://doc.babylonjs.com/babylon101/particles
  1169. */
  1170. particleSystems: IParticleSystem[];
  1171. /**
  1172. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1173. */
  1174. spritesEnabled: boolean;
  1175. /**
  1176. * All of the sprite managers added to this scene
  1177. * @see http://doc.babylonjs.com/babylon101/sprites
  1178. */
  1179. spriteManagers: SpriteManager[];
  1180. /**
  1181. * The list of layers (background and foreground) of the scene
  1182. */
  1183. layers: Layer[];
  1184. /**
  1185. * The list of effect layers (highlights/glow) added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1187. * @see http://doc.babylonjs.com/how_to/glow_layer
  1188. */
  1189. effectLayers: EffectLayer[];
  1190. private _skeletonsEnabled;
  1191. /**
  1192. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1193. */
  1194. skeletonsEnabled: boolean;
  1195. /**
  1196. * The list of skeletons added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1198. */
  1199. skeletons: Skeleton[];
  1200. /**
  1201. * The list of morph target managers added to the scene
  1202. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1203. */
  1204. morphTargetManagers: MorphTargetManager[];
  1205. /**
  1206. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1207. */
  1208. lensFlaresEnabled: boolean;
  1209. /**
  1210. * The list of lens flare system added to the scene
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1212. */
  1213. lensFlareSystems: LensFlareSystem[];
  1214. /**
  1215. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1217. */
  1218. collisionsEnabled: boolean;
  1219. private _workerCollisions;
  1220. /** @hidden */
  1221. collisionCoordinator: ICollisionCoordinator;
  1222. /**
  1223. * Defines the gravity applied to this scene (used only for collisions)
  1224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1225. */
  1226. gravity: Vector3;
  1227. /**
  1228. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1229. */
  1230. postProcessesEnabled: boolean;
  1231. /**
  1232. * The list of postprocesses added to the scene
  1233. */
  1234. postProcesses: PostProcess[];
  1235. /**
  1236. * Gets the current postprocess manager
  1237. */
  1238. postProcessManager: PostProcessManager;
  1239. private _postProcessRenderPipelineManager;
  1240. /**
  1241. * Gets the postprocess render pipeline manager
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1243. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1244. */
  1245. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1246. /**
  1247. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1248. */
  1249. renderTargetsEnabled: boolean;
  1250. /**
  1251. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1252. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1253. */
  1254. dumpNextRenderTargets: boolean;
  1255. /**
  1256. * The list of user defined render targets added to the scene
  1257. */
  1258. customRenderTargets: RenderTargetTexture[];
  1259. /**
  1260. * Defines if texture loading must be delayed
  1261. * If true, textures will only be loaded when they need to be rendered
  1262. */
  1263. useDelayedTextureLoading: boolean;
  1264. /**
  1265. * Gets the list of meshes imported to the scene through SceneLoader
  1266. */
  1267. importedMeshesFiles: String[];
  1268. /**
  1269. * Gets or sets a boolean indicating if probes are enabled on this scene
  1270. */
  1271. probesEnabled: boolean;
  1272. /**
  1273. * The list of reflection probes added to the scene
  1274. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1275. */
  1276. reflectionProbes: ReflectionProbe[];
  1277. /**
  1278. * @hidden
  1279. */
  1280. database: Database;
  1281. /**
  1282. * Gets or sets the action manager associated with the scene
  1283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1284. */
  1285. actionManager: ActionManager;
  1286. /** @hidden */
  1287. _actionManagers: ActionManager[];
  1288. private _meshesForIntersections;
  1289. /**
  1290. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1291. */
  1292. proceduralTexturesEnabled: boolean;
  1293. /**
  1294. * The list of procedural textures added to the scene
  1295. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1296. */
  1297. proceduralTextures: ProceduralTexture[];
  1298. private _mainSoundTrack;
  1299. /**
  1300. * The list of sound tracks added to the scene
  1301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1302. */
  1303. soundTracks: SoundTrack[];
  1304. private _audioEnabled;
  1305. private _headphone;
  1306. /**
  1307. * Gets the main soundtrack associated with the scene
  1308. */
  1309. readonly mainSoundTrack: SoundTrack;
  1310. /**
  1311. * Gets or sets the VRExperienceHelper attached to the scene
  1312. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1313. * @ignorenaming
  1314. */
  1315. VRHelper: VRExperienceHelper;
  1316. /**
  1317. * Gets or sets the simplification queue attached to the scene
  1318. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1319. */
  1320. simplificationQueue: SimplificationQueue;
  1321. private _engine;
  1322. private _totalVertices;
  1323. /** @hidden */
  1324. _activeIndices: PerfCounter;
  1325. /** @hidden */
  1326. _activeParticles: PerfCounter;
  1327. /** @hidden */
  1328. _activeBones: PerfCounter;
  1329. private _animationRatio;
  1330. private _animationTimeLast;
  1331. private _animationTime;
  1332. /**
  1333. * Gets or sets a general scale for animation speed
  1334. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1335. */
  1336. animationTimeScale: number;
  1337. /** @hidden */
  1338. _cachedMaterial: Nullable<Material>;
  1339. /** @hidden */
  1340. _cachedEffect: Nullable<Effect>;
  1341. /** @hidden */
  1342. _cachedVisibility: Nullable<number>;
  1343. private _renderId;
  1344. private _executeWhenReadyTimeoutId;
  1345. private _intermediateRendering;
  1346. private _viewUpdateFlag;
  1347. private _projectionUpdateFlag;
  1348. private _alternateViewUpdateFlag;
  1349. private _alternateProjectionUpdateFlag;
  1350. /** @hidden */
  1351. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1352. private _activeRequests;
  1353. private _pendingData;
  1354. private _isDisposed;
  1355. /**
  1356. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1357. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1358. */
  1359. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1360. private _activeMeshes;
  1361. private _processedMaterials;
  1362. private _renderTargets;
  1363. /** @hidden */
  1364. _activeParticleSystems: SmartArray<IParticleSystem>;
  1365. private _activeSkeletons;
  1366. private _softwareSkinnedMeshes;
  1367. private _renderingManager;
  1368. private _physicsEngine;
  1369. /** @hidden */
  1370. _activeAnimatables: Animatable[];
  1371. private _transformMatrix;
  1372. private _sceneUbo;
  1373. private _alternateSceneUbo;
  1374. private _pickWithRayInverseMatrix;
  1375. private _boundingBoxRenderer;
  1376. private _outlineRenderer;
  1377. private _viewMatrix;
  1378. private _projectionMatrix;
  1379. private _alternateViewMatrix;
  1380. private _alternateProjectionMatrix;
  1381. private _alternateTransformMatrix;
  1382. private _useAlternateCameraConfiguration;
  1383. private _alternateRendering;
  1384. /** @hidden */
  1385. _forcedViewPosition: Nullable<Vector3>;
  1386. /** @hidden */
  1387. readonly _isAlternateRenderingEnabled: boolean;
  1388. private _frustumPlanes;
  1389. /**
  1390. * Gets the list of frustum planes (built from the active camera)
  1391. */
  1392. readonly frustumPlanes: Plane[];
  1393. /**
  1394. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1395. * This is useful if there are more lights that the maximum simulteanous authorized
  1396. */
  1397. requireLightSorting: boolean;
  1398. private _selectionOctree;
  1399. private _pointerOverMesh;
  1400. private _pointerOverSprite;
  1401. private _debugLayer;
  1402. private _depthRenderer;
  1403. private _geometryBufferRenderer;
  1404. /**
  1405. * Gets the current geometry buffer associated to the scene.
  1406. */
  1407. /**
  1408. * Sets the current geometry buffer for the scene.
  1409. */
  1410. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1411. private _pickedDownMesh;
  1412. private _pickedUpMesh;
  1413. private _pickedDownSprite;
  1414. private _externalData;
  1415. private _uid;
  1416. /**
  1417. * Creates a new Scene
  1418. * @param engine defines the engine to use to render this scene
  1419. */
  1420. constructor(engine: Engine);
  1421. /**
  1422. * Gets the debug layer associated with the scene
  1423. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1424. */
  1425. readonly debugLayer: DebugLayer;
  1426. /**
  1427. * Gets a boolean indicating if collisions are processed on a web worker
  1428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1429. */
  1430. workerCollisions: boolean;
  1431. /**
  1432. * Gets the octree used to boost mesh selection (picking)
  1433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1434. */
  1435. readonly selectionOctree: Octree<AbstractMesh>;
  1436. /**
  1437. * Gets the mesh that is currently under the pointer
  1438. */
  1439. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1440. /**
  1441. * Gets the current on-screen X position of the pointer
  1442. */
  1443. readonly pointerX: number;
  1444. /**
  1445. * Gets the current on-screen Y position of the pointer
  1446. */
  1447. readonly pointerY: number;
  1448. /**
  1449. * Gets the cached material (ie. the latest rendered one)
  1450. * @returns the cached material
  1451. */
  1452. getCachedMaterial(): Nullable<Material>;
  1453. /**
  1454. * Gets the cached effect (ie. the latest rendered one)
  1455. * @returns the cached effect
  1456. */
  1457. getCachedEffect(): Nullable<Effect>;
  1458. /**
  1459. * Gets the cached visibility state (ie. the latest rendered one)
  1460. * @returns the cached visibility state
  1461. */
  1462. getCachedVisibility(): Nullable<number>;
  1463. /**
  1464. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1465. * @param material defines the current material
  1466. * @param effect defines the current effect
  1467. * @param visibility defines the current visibility state
  1468. * @returns true if one parameter is not cached
  1469. */
  1470. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1471. /**
  1472. * Gets the bounding box renderer associated with the scene
  1473. * @returns a BoundingBoxRenderer
  1474. */
  1475. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1476. /**
  1477. * Gets the outline renderer associated with the scene
  1478. * @returns a OutlineRenderer
  1479. */
  1480. getOutlineRenderer(): OutlineRenderer;
  1481. /**
  1482. * Gets the engine associated with the scene
  1483. * @returns an Engine
  1484. */
  1485. getEngine(): Engine;
  1486. /**
  1487. * Gets the total number of vertices rendered per frame
  1488. * @returns the total number of vertices rendered per frame
  1489. */
  1490. getTotalVertices(): number;
  1491. /**
  1492. * Gets the performance counter for total vertices
  1493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1494. */
  1495. readonly totalVerticesPerfCounter: PerfCounter;
  1496. /**
  1497. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1498. * @returns the total number of active indices rendered per frame
  1499. */
  1500. getActiveIndices(): number;
  1501. /**
  1502. * Gets the performance counter for active indices
  1503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1504. */
  1505. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1506. /**
  1507. * Gets the total number of active particles rendered per frame
  1508. * @returns the total number of active particles rendered per frame
  1509. */
  1510. getActiveParticles(): number;
  1511. /**
  1512. * Gets the performance counter for active particles
  1513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1514. */
  1515. readonly activeParticlesPerfCounter: PerfCounter;
  1516. /**
  1517. * Gets the total number of active bones rendered per frame
  1518. * @returns the total number of active bones rendered per frame
  1519. */
  1520. getActiveBones(): number;
  1521. /**
  1522. * Gets the performance counter for active bones
  1523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1524. */
  1525. readonly activeBonesPerfCounter: PerfCounter;
  1526. /** @hidden */
  1527. getInterFramePerfCounter(): number;
  1528. /** @hidden */
  1529. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1530. /** @hidden */
  1531. getLastFrameDuration(): number;
  1532. /** @hidden */
  1533. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1534. /** @hidden */
  1535. getEvaluateActiveMeshesDuration(): number;
  1536. /** @hidden */
  1537. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1538. /**
  1539. * Gets the array of active meshes
  1540. * @returns an array of AbstractMesh
  1541. */
  1542. getActiveMeshes(): SmartArray<AbstractMesh>;
  1543. /** @hidden */
  1544. getRenderTargetsDuration(): number;
  1545. /** @hidden */
  1546. getRenderDuration(): number;
  1547. /** @hidden */
  1548. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1549. /** @hidden */
  1550. getParticlesDuration(): number;
  1551. /** @hidden */
  1552. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1553. /** @hidden */
  1554. getSpritesDuration(): number;
  1555. /** @hidden */
  1556. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1557. /**
  1558. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1559. * @returns a number
  1560. */
  1561. getAnimationRatio(): number;
  1562. /**
  1563. * Gets an unique Id for the current frame
  1564. * @returns a number
  1565. */
  1566. getRenderId(): number;
  1567. /** Call this function if you want to manually increment the render Id*/
  1568. incrementRenderId(): void;
  1569. private _updatePointerPosition(evt);
  1570. private _createUbo();
  1571. private _createAlternateUbo();
  1572. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1573. private _setRayOnPointerInfo(pointerInfo);
  1574. /**
  1575. * Use this method to simulate a pointer move on a mesh
  1576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1579. * @returns the current scene
  1580. */
  1581. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1582. private _processPointerMove(pickResult, evt);
  1583. private _checkPrePointerObservable(pickResult, evt, type);
  1584. /**
  1585. * Use this method to simulate a pointer down on a mesh
  1586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1589. * @returns the current scene
  1590. */
  1591. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1592. private _processPointerDown(pickResult, evt);
  1593. /**
  1594. * Use this method to simulate a pointer up on a mesh
  1595. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1596. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1597. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1598. * @returns the current scene
  1599. */
  1600. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1601. private _processPointerUp(pickResult, evt, clickInfo);
  1602. /**
  1603. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1604. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1605. * @returns true if the pointer was captured
  1606. */
  1607. isPointerCaptured(pointerId?: number): boolean;
  1608. /**
  1609. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1610. * @param attachUp defines if you want to attach events to pointerup
  1611. * @param attachDown defines if you want to attach events to pointerdown
  1612. * @param attachMove defines if you want to attach events to pointermove
  1613. */
  1614. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1615. /** Detaches all event handlers*/
  1616. detachControl(): void;
  1617. /**
  1618. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1619. * Delay loaded resources are not taking in account
  1620. * @return true if all required resources are ready
  1621. */
  1622. isReady(): boolean;
  1623. /** Resets all cached information relative to material (including effect and visibility) */
  1624. resetCachedMaterial(): void;
  1625. /**
  1626. * Registers a function to be called before every frame render
  1627. * @param func defines the function to register
  1628. */
  1629. registerBeforeRender(func: () => void): void;
  1630. /**
  1631. * Unregisters a function called before every frame render
  1632. * @param func defines the function to unregister
  1633. */
  1634. unregisterBeforeRender(func: () => void): void;
  1635. /**
  1636. * Registers a function to be called after every frame render
  1637. * @param func defines the function to register
  1638. */
  1639. registerAfterRender(func: () => void): void;
  1640. /**
  1641. * Unregisters a function called after every frame render
  1642. * @param func defines the function to unregister
  1643. */
  1644. unregisterAfterRender(func: () => void): void;
  1645. private _executeOnceBeforeRender(func);
  1646. /**
  1647. * The provided function will run before render once and will be disposed afterwards.
  1648. * A timeout delay can be provided so that the function will be executed in N ms.
  1649. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1650. * @param func The function to be executed.
  1651. * @param timeout optional delay in ms
  1652. */
  1653. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1654. /** @hidden */
  1655. _addPendingData(data: any): void;
  1656. /** @hidden */
  1657. _removePendingData(data: any): void;
  1658. /**
  1659. * Returns the number of items waiting to be loaded
  1660. * @returns the number of items waiting to be loaded
  1661. */
  1662. getWaitingItemsCount(): number;
  1663. /**
  1664. * Returns a boolean indicating if the scene is still loading data
  1665. */
  1666. readonly isLoading: boolean;
  1667. /**
  1668. * Registers a function to be executed when the scene is ready
  1669. * @param {Function} func - the function to be executed
  1670. */
  1671. executeWhenReady(func: () => void): void;
  1672. /**
  1673. * Returns a promise that resolves when the scene is ready
  1674. * @returns A promise that resolves when the scene is ready
  1675. */
  1676. whenReadyAsync(): Promise<void>;
  1677. /** @hidden */
  1678. _checkIsReady(): void;
  1679. /**
  1680. * Will start the animation sequence of a given target
  1681. * @param target defines the target
  1682. * @param from defines from which frame should animation start
  1683. * @param to defines until which frame should animation run.
  1684. * @param weight defines the weight to apply to the animation (1.0 by default)
  1685. * @param loop defines if the animation loops
  1686. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1687. * @param onAnimationEnd defines the function to be executed when the animation ends
  1688. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1689. * @returns the animatable object created for this animation
  1690. */
  1691. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1692. /**
  1693. * Will start the animation sequence of a given target
  1694. * @param target defines the target
  1695. * @param from defines from which frame should animation start
  1696. * @param to defines until which frame should animation run.
  1697. * @param loop defines if the animation loops
  1698. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1699. * @param onAnimationEnd defines the function to be executed when the animation ends
  1700. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1701. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1702. * @returns the animatable object created for this animation
  1703. */
  1704. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1705. /**
  1706. * Begin a new animation on a given node
  1707. * @param target defines the target where the animation will take place
  1708. * @param animations defines the list of animations to start
  1709. * @param from defines the initial value
  1710. * @param to defines the final value
  1711. * @param loop defines if you want animation to loop (off by default)
  1712. * @param speedRatio defines the speed ratio to apply to all animations
  1713. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1714. * @returns the list of created animatables
  1715. */
  1716. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1717. /**
  1718. * Begin a new animation on a given node and its hierarchy
  1719. * @param target defines the root node where the animation will take place
  1720. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1721. * @param animations defines the list of animations to start
  1722. * @param from defines the initial value
  1723. * @param to defines the final value
  1724. * @param loop defines if you want animation to loop (off by default)
  1725. * @param speedRatio defines the speed ratio to apply to all animations
  1726. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1727. * @returns the list of animatables created for all nodes
  1728. */
  1729. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1730. /**
  1731. * Gets the animatable associated with a specific target
  1732. * @param target defines the target of the animatable
  1733. * @returns the required animatable if found
  1734. */
  1735. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1736. /**
  1737. * Gets all animatables associated with a given target
  1738. * @param target defines the target to look animatables for
  1739. * @returns an array of Animatables
  1740. */
  1741. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1742. /**
  1743. * Gets all animatable attached to the scene
  1744. */
  1745. readonly animatables: Animatable[];
  1746. /**
  1747. * Will stop the animation of the given target
  1748. * @param target - the target
  1749. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1750. */
  1751. stopAnimation(target: any, animationName?: string): void;
  1752. /**
  1753. * Stops and removes all animations that have been applied to the scene
  1754. */
  1755. stopAllAnimations(): void;
  1756. private _animate();
  1757. /** @hidden */
  1758. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1759. private _processLateAnimationBindingsForMatrices(holder);
  1760. private _processLateAnimationBindingsForQuaternions(holder);
  1761. private _processLateAnimationBindings();
  1762. /** @hidden */
  1763. _switchToAlternateCameraConfiguration(active: boolean): void;
  1764. /**
  1765. * Gets the current view matrix
  1766. * @returns a Matrix
  1767. */
  1768. getViewMatrix(): Matrix;
  1769. /**
  1770. * Gets the current projection matrix
  1771. * @returns a Matrix
  1772. */
  1773. getProjectionMatrix(): Matrix;
  1774. /**
  1775. * Gets the current transform matrix
  1776. * @returns a Matrix made of View * Projection
  1777. */
  1778. getTransformMatrix(): Matrix;
  1779. /**
  1780. * Sets the current transform matrix
  1781. * @param view defines the View matrix to use
  1782. * @param projection defines the Projection matrix to use
  1783. */
  1784. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1785. /** @hidden */
  1786. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1787. /**
  1788. * Gets the uniform buffer used to store scene data
  1789. * @returns a UniformBuffer
  1790. */
  1791. getSceneUniformBuffer(): UniformBuffer;
  1792. /**
  1793. * Gets an unique (relatively to the current scene) Id
  1794. * @returns an unique number for the scene
  1795. */
  1796. getUniqueId(): number;
  1797. /**
  1798. * Add a mesh to the list of scene's meshes
  1799. * @param newMesh defines the mesh to add
  1800. * @param recursive if all child meshes should also be added to the scene
  1801. */
  1802. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1803. /**
  1804. * Remove a mesh for the list of scene's meshes
  1805. * @param toRemove defines the mesh to remove
  1806. * @param recursive if all child meshes should also be removed from the scene
  1807. * @returns the index where the mesh was in the mesh list
  1808. */
  1809. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1810. /**
  1811. * Add a transform node to the list of scene's transform nodes
  1812. * @param newTransformNode defines the transform node to add
  1813. */
  1814. addTransformNode(newTransformNode: TransformNode): void;
  1815. /**
  1816. * Remove a transform node for the list of scene's transform nodes
  1817. * @param toRemove defines the transform node to remove
  1818. * @returns the index where the transform node was in the transform node list
  1819. */
  1820. removeTransformNode(toRemove: TransformNode): number;
  1821. /**
  1822. * Remove a skeleton for the list of scene's skeletons
  1823. * @param toRemove defines the skeleton to remove
  1824. * @returns the index where the skeleton was in the skeleton list
  1825. */
  1826. removeSkeleton(toRemove: Skeleton): number;
  1827. /**
  1828. * Remove a morph target for the list of scene's morph targets
  1829. * @param toRemove defines the morph target to remove
  1830. * @returns the index where the morph target was in the morph target list
  1831. */
  1832. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1833. /**
  1834. * Remove a light for the list of scene's lights
  1835. * @param toRemove defines the light to remove
  1836. * @returns the index where the light was in the light list
  1837. */
  1838. removeLight(toRemove: Light): number;
  1839. /**
  1840. * Remove a camera for the list of scene's cameras
  1841. * @param toRemove defines the camera to remove
  1842. * @returns the index where the camera was in the camera list
  1843. */
  1844. removeCamera(toRemove: Camera): number;
  1845. /**
  1846. * Remove a particle system for the list of scene's particle systems
  1847. * @param toRemove defines the particle system to remove
  1848. * @returns the index where the particle system was in the particle system list
  1849. */
  1850. removeParticleSystem(toRemove: IParticleSystem): number;
  1851. /**
  1852. * Remove a animation for the list of scene's animations
  1853. * @param toRemove defines the animation to remove
  1854. * @returns the index where the animation was in the animation list
  1855. */
  1856. removeAnimation(toRemove: Animation): number;
  1857. /**
  1858. * Removes the given animation group from this scene.
  1859. * @param toRemove The animation group to remove
  1860. * @returns The index of the removed animation group
  1861. */
  1862. removeAnimationGroup(toRemove: AnimationGroup): number;
  1863. /**
  1864. * Removes the given multi-material from this scene.
  1865. * @param toRemove The multi-material to remove
  1866. * @returns The index of the removed multi-material
  1867. */
  1868. removeMultiMaterial(toRemove: MultiMaterial): number;
  1869. /**
  1870. * Removes the given material from this scene.
  1871. * @param toRemove The material to remove
  1872. * @returns The index of the removed material
  1873. */
  1874. removeMaterial(toRemove: Material): number;
  1875. /**
  1876. * Removes the given lens flare system from this scene.
  1877. * @param toRemove The lens flare system to remove
  1878. * @returns The index of the removed lens flare system
  1879. */
  1880. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1881. /**
  1882. * Removes the given action manager from this scene.
  1883. * @param toRemove The action manager to remove
  1884. * @returns The index of the removed action manager
  1885. */
  1886. removeActionManager(toRemove: ActionManager): number;
  1887. /**
  1888. * Removes the given effect layer from this scene.
  1889. * @param toRemove defines the effect layer to remove
  1890. * @returns the index of the removed effect layer
  1891. */
  1892. removeEffectLayer(toRemove: EffectLayer): number;
  1893. /**
  1894. * Removes the given texture from this scene.
  1895. * @param toRemove The texture to remove
  1896. * @returns The index of the removed texture
  1897. */
  1898. removeTexture(toRemove: BaseTexture): number;
  1899. /**
  1900. * Adds the given light to this scene
  1901. * @param newLight The light to add
  1902. */
  1903. addLight(newLight: Light): void;
  1904. /**
  1905. * Sorts the list list based on light priorities
  1906. */
  1907. sortLightsByPriority(): void;
  1908. /**
  1909. * Adds the given camera to this scene
  1910. * @param newCamera The camera to add
  1911. */
  1912. addCamera(newCamera: Camera): void;
  1913. /**
  1914. * Adds the given skeleton to this scene
  1915. * @param newSkeleton The skeleton to add
  1916. */
  1917. addSkeleton(newSkeleton: Skeleton): void;
  1918. /**
  1919. * Adds the given particle system to this scene
  1920. * @param newParticleSystem The particle system to add
  1921. */
  1922. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1923. /**
  1924. * Adds the given animation to this scene
  1925. * @param newAnimation The animation to add
  1926. */
  1927. addAnimation(newAnimation: Animation): void;
  1928. /**
  1929. * Adds the given animation group to this scene.
  1930. * @param newAnimationGroup The animation group to add
  1931. */
  1932. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1933. /**
  1934. * Adds the given multi-material to this scene
  1935. * @param newMultiMaterial The multi-material to add
  1936. */
  1937. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1938. /**
  1939. * Adds the given material to this scene
  1940. * @param newMaterial The material to add
  1941. */
  1942. addMaterial(newMaterial: Material): void;
  1943. /**
  1944. * Adds the given morph target to this scene
  1945. * @param newMorphTargetManager The morph target to add
  1946. */
  1947. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1948. /**
  1949. * Adds the given geometry to this scene
  1950. * @param newGeometry The geometry to add
  1951. */
  1952. addGeometry(newGeometry: Geometry): void;
  1953. /**
  1954. * Adds the given lens flare system to this scene
  1955. * @param newLensFlareSystem The lens flare system to add
  1956. */
  1957. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1958. /**
  1959. * Adds the given effect layer to this scene
  1960. * @param newEffectLayer defines the effect layer to add
  1961. */
  1962. addEffectLayer(newEffectLayer: EffectLayer): void;
  1963. /**
  1964. * Adds the given action manager to this scene
  1965. * @param newActionManager The action manager to add
  1966. */
  1967. addActionManager(newActionManager: ActionManager): void;
  1968. /**
  1969. * Adds the given texture to this scene.
  1970. * @param newTexture The texture to add
  1971. */
  1972. addTexture(newTexture: BaseTexture): void;
  1973. /**
  1974. * Switch active camera
  1975. * @param newCamera defines the new active camera
  1976. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1977. */
  1978. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1979. /**
  1980. * sets the active camera of the scene using its ID
  1981. * @param id defines the camera's ID
  1982. * @return the new active camera or null if none found.
  1983. */
  1984. setActiveCameraByID(id: string): Nullable<Camera>;
  1985. /**
  1986. * sets the active camera of the scene using its name
  1987. * @param name defines the camera's name
  1988. * @returns the new active camera or null if none found.
  1989. */
  1990. setActiveCameraByName(name: string): Nullable<Camera>;
  1991. /**
  1992. * get an animation group using its name
  1993. * @param name defines the material's name
  1994. * @return the animation group or null if none found.
  1995. */
  1996. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1997. /**
  1998. * get a material using its id
  1999. * @param id defines the material's ID
  2000. * @return the material or null if none found.
  2001. */
  2002. getMaterialByID(id: string): Nullable<Material>;
  2003. /**
  2004. * Gets a material using its name
  2005. * @param name defines the material's name
  2006. * @return the material or null if none found.
  2007. */
  2008. getMaterialByName(name: string): Nullable<Material>;
  2009. /**
  2010. * Gets a lens flare system using its name
  2011. * @param name defines the name to look for
  2012. * @returns the lens flare system or null if not found
  2013. */
  2014. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  2015. /**
  2016. * Gets a lens flare system using its id
  2017. * @param id defines the id to look for
  2018. * @returns the lens flare system or null if not found
  2019. */
  2020. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2021. /**
  2022. * Gets a camera using its id
  2023. * @param id defines the id to look for
  2024. * @returns the camera or null if not found
  2025. */
  2026. getCameraByID(id: string): Nullable<Camera>;
  2027. /**
  2028. * Gets a camera using its unique id
  2029. * @param uniqueId defines the unique id to look for
  2030. * @returns the camera or null if not found
  2031. */
  2032. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2033. /**
  2034. * Gets a camera using its name
  2035. * @param name defines the camera's name
  2036. * @return the camera or null if none found.
  2037. */
  2038. getCameraByName(name: string): Nullable<Camera>;
  2039. /**
  2040. * Gets a bone using its id
  2041. * @param id defines the bone's id
  2042. * @return the bone or null if not found
  2043. */
  2044. getBoneByID(id: string): Nullable<Bone>;
  2045. /**
  2046. * Gets a bone using its id
  2047. * @param name defines the bone's name
  2048. * @return the bone or null if not found
  2049. */
  2050. getBoneByName(name: string): Nullable<Bone>;
  2051. /**
  2052. * Gets a light node using its name
  2053. * @param name defines the the light's name
  2054. * @return the light or null if none found.
  2055. */
  2056. getLightByName(name: string): Nullable<Light>;
  2057. /**
  2058. * Gets a light node using its id
  2059. * @param id defines the light's id
  2060. * @return the light or null if none found.
  2061. */
  2062. getLightByID(id: string): Nullable<Light>;
  2063. /**
  2064. * Gets a light node using its scene-generated unique ID
  2065. * @param uniqueId defines the light's unique id
  2066. * @return the light or null if none found.
  2067. */
  2068. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2069. /**
  2070. * Gets a particle system by id
  2071. * @param id defines the particle system id
  2072. * @return the corresponding system or null if none found
  2073. */
  2074. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2075. /**
  2076. * Gets a geometry using its ID
  2077. * @param id defines the geometry's id
  2078. * @return the geometry or null if none found.
  2079. */
  2080. getGeometryByID(id: string): Nullable<Geometry>;
  2081. /**
  2082. * Add a new geometry to this scene
  2083. * @param geometry defines the geometry to be added to the scene.
  2084. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2085. * @return a boolean defining if the geometry was added or not
  2086. */
  2087. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2088. /**
  2089. * Removes an existing geometry
  2090. * @param geometry defines the geometry to be removed from the scene
  2091. * @return a boolean defining if the geometry was removed or not
  2092. */
  2093. removeGeometry(geometry: Geometry): boolean;
  2094. /**
  2095. * Gets the list of geometries attached to the scene
  2096. * @returns an array of Geometry
  2097. */
  2098. getGeometries(): Geometry[];
  2099. /**
  2100. * Gets the first added mesh found of a given ID
  2101. * @param id defines the id to search for
  2102. * @return the mesh found or null if not found at all
  2103. */
  2104. getMeshByID(id: string): Nullable<AbstractMesh>;
  2105. /**
  2106. * Gets a list of meshes using their id
  2107. * @param id defines the id to search for
  2108. * @returns a list of meshes
  2109. */
  2110. getMeshesByID(id: string): Array<AbstractMesh>;
  2111. /**
  2112. * Gets the first added transform node found of a given ID
  2113. * @param id defines the id to search for
  2114. * @return the found transform node or null if not found at all.
  2115. */
  2116. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2117. /**
  2118. * Gets a list of transform nodes using their id
  2119. * @param id defines the id to search for
  2120. * @returns a list of transform nodes
  2121. */
  2122. getTransformNodesByID(id: string): Array<TransformNode>;
  2123. /**
  2124. * Gets a mesh with its auto-generated unique id
  2125. * @param uniqueId defines the unique id to search for
  2126. * @return the found mesh or null if not found at all.
  2127. */
  2128. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2129. /**
  2130. * Gets a the last added mesh using a given id
  2131. * @param id defines the id to search for
  2132. * @return the found mesh or null if not found at all.
  2133. */
  2134. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2135. /**
  2136. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2137. * @param id defines the id to search for
  2138. * @return the found node or null if not found at all
  2139. */
  2140. getLastEntryByID(id: string): Nullable<Node>;
  2141. /**
  2142. * Gets a node (Mesh, Camera, Light) using a given id
  2143. * @param id defines the id to search for
  2144. * @return the found node or null if not found at all
  2145. */
  2146. getNodeByID(id: string): Nullable<Node>;
  2147. /**
  2148. * Gets a node (Mesh, Camera, Light) using a given name
  2149. * @param name defines the name to search for
  2150. * @return the found node or null if not found at all.
  2151. */
  2152. getNodeByName(name: string): Nullable<Node>;
  2153. /**
  2154. * Gets a mesh using a given name
  2155. * @param name defines the name to search for
  2156. * @return the found mesh or null if not found at all.
  2157. */
  2158. getMeshByName(name: string): Nullable<AbstractMesh>;
  2159. /**
  2160. * Gets a transform node using a given name
  2161. * @param name defines the name to search for
  2162. * @return the found transform node or null if not found at all.
  2163. */
  2164. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2165. /**
  2166. * Gets a sound using a given name
  2167. * @param name defines the name to search for
  2168. * @return the found sound or null if not found at all.
  2169. */
  2170. getSoundByName(name: string): Nullable<Sound>;
  2171. /**
  2172. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2173. * @param id defines the id to search for
  2174. * @return the found skeleton or null if not found at all.
  2175. */
  2176. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2177. /**
  2178. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2179. * @param id defines the id to search for
  2180. * @return the found skeleton or null if not found at all.
  2181. */
  2182. getSkeletonById(id: string): Nullable<Skeleton>;
  2183. /**
  2184. * Gets a skeleton using a given name
  2185. * @param name defines the name to search for
  2186. * @return the found skeleton or null if not found at all.
  2187. */
  2188. getSkeletonByName(name: string): Nullable<Skeleton>;
  2189. /**
  2190. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2191. * @param id defines the id to search for
  2192. * @return the found morph target manager or null if not found at all.
  2193. */
  2194. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2195. /**
  2196. * Gets a boolean indicating if the given mesh is active
  2197. * @param mesh defines the mesh to look for
  2198. * @returns true if the mesh is in the active list
  2199. */
  2200. isActiveMesh(mesh: AbstractMesh): boolean;
  2201. /**
  2202. * Return a the first highlight layer of the scene with a given name.
  2203. * @param name The name of the highlight layer to look for.
  2204. * @return The highlight layer if found otherwise null.
  2205. */
  2206. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2207. /**
  2208. * Return a the first highlight layer of the scene with a given name.
  2209. * @param name The name of the highlight layer to look for.
  2210. * @return The highlight layer if found otherwise null.
  2211. */
  2212. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2213. /**
  2214. * Return a unique id as a string which can serve as an identifier for the scene
  2215. */
  2216. readonly uid: string;
  2217. /**
  2218. * Add an externaly attached data from its key.
  2219. * This method call will fail and return false, if such key already exists.
  2220. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2221. * @param key the unique key that identifies the data
  2222. * @param data the data object to associate to the key for this Engine instance
  2223. * @return true if no such key were already present and the data was added successfully, false otherwise
  2224. */
  2225. addExternalData<T>(key: string, data: T): boolean;
  2226. /**
  2227. * Get an externaly attached data from its key
  2228. * @param key the unique key that identifies the data
  2229. * @return the associated data, if present (can be null), or undefined if not present
  2230. */
  2231. getExternalData<T>(key: string): Nullable<T>;
  2232. /**
  2233. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2234. * @param key the unique key that identifies the data
  2235. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2236. * @return the associated data, can be null if the factory returned null.
  2237. */
  2238. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2239. /**
  2240. * Remove an externaly attached data from the Engine instance
  2241. * @param key the unique key that identifies the data
  2242. * @return true if the data was successfully removed, false if it doesn't exist
  2243. */
  2244. removeExternalData(key: string): boolean;
  2245. private _evaluateSubMesh(subMesh, mesh);
  2246. /**
  2247. * Clear the processed materials smart array preventing retention point in material dispose.
  2248. */
  2249. freeProcessedMaterials(): void;
  2250. /**
  2251. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2252. */
  2253. freeActiveMeshes(): void;
  2254. /**
  2255. * Clear the info related to rendering groups preventing retention points during dispose.
  2256. */
  2257. freeRenderingGroups(): void;
  2258. /** @hidden */
  2259. _isInIntermediateRendering(): boolean;
  2260. private _activeMeshCandidateProvider;
  2261. /**
  2262. * Defines the current active mesh candidate provider
  2263. * @param provider defines the provider to use
  2264. */
  2265. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2266. /**
  2267. * Gets the current active mesh candidate provider
  2268. * @returns the current active mesh candidate provider
  2269. */
  2270. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2271. private _activeMeshesFrozen;
  2272. /**
  2273. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2274. * @returns the current scene
  2275. */
  2276. freezeActiveMeshes(): Scene;
  2277. /**
  2278. * Use this function to restart evaluating active meshes on every frame
  2279. * @returns the current scene
  2280. */
  2281. unfreezeActiveMeshes(): Scene;
  2282. private _evaluateActiveMeshes();
  2283. private _activeMesh(sourceMesh, mesh);
  2284. /**
  2285. * Update the transform matrix to update from the current active camera
  2286. * @param force defines a boolean used to force the update even if cache is up to date
  2287. */
  2288. updateTransformMatrix(force?: boolean): void;
  2289. /**
  2290. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2291. * @param alternateCamera defines the camera to use
  2292. */
  2293. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2294. private _renderForCamera(camera, rigParent?);
  2295. private _processSubCameras(camera);
  2296. private _checkIntersections();
  2297. /**
  2298. * Render the scene
  2299. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2300. */
  2301. render(updateCameras?: boolean): void;
  2302. private _updateAudioParameters();
  2303. /**
  2304. * Gets or sets if audio support is enabled
  2305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2306. */
  2307. audioEnabled: boolean;
  2308. private _disableAudio();
  2309. private _enableAudio();
  2310. /**
  2311. * Gets or sets if audio will be output to headphones
  2312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2313. */
  2314. headphone: boolean;
  2315. private _switchAudioModeForHeadphones();
  2316. private _switchAudioModeForNormalSpeakers();
  2317. /**
  2318. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2319. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2320. * @returns the created depth renderer
  2321. */
  2322. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2323. /**
  2324. * Disables a depth renderer for a given camera
  2325. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2326. */
  2327. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2328. /**
  2329. * Enables a GeometryBufferRender and associates it with the scene
  2330. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2331. * @returns the GeometryBufferRenderer
  2332. */
  2333. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2334. /**
  2335. * Disables the GeometryBufferRender associated with the scene
  2336. */
  2337. disableGeometryBufferRenderer(): void;
  2338. /**
  2339. * Freeze all materials
  2340. * A frozen material will not be updatable but should be faster to render
  2341. */
  2342. freezeMaterials(): void;
  2343. /**
  2344. * Unfreeze all materials
  2345. * A frozen material will not be updatable but should be faster to render
  2346. */
  2347. unfreezeMaterials(): void;
  2348. /**
  2349. * Releases all held ressources
  2350. */
  2351. dispose(): void;
  2352. /**
  2353. * Gets if the scene is already disposed
  2354. */
  2355. readonly isDisposed: boolean;
  2356. /**
  2357. * Releases sounds & soundtracks
  2358. */
  2359. disposeSounds(): void;
  2360. /**
  2361. * Call this function to reduce memory footprint of the scene.
  2362. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2363. */
  2364. clearCachedVertexData(): void;
  2365. /**
  2366. * This function will remove the local cached buffer data from texture.
  2367. * It will save memory but will prevent the texture from being rebuilt
  2368. */
  2369. cleanCachedTextureBuffer(): void;
  2370. /**
  2371. * Get the world extend vectors with an optional filter
  2372. *
  2373. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2374. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2375. */
  2376. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2377. min: Vector3;
  2378. max: Vector3;
  2379. };
  2380. /**
  2381. * Creates or updates the octree used to boost selection (picking)
  2382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2383. * @param maxCapacity defines the maximum capacity per leaf
  2384. * @param maxDepth defines the maximum depth of the octree
  2385. * @returns an octree of AbstractMesh
  2386. */
  2387. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2388. /**
  2389. * Creates a ray that can be used to pick in the scene
  2390. * @param x defines the x coordinate of the origin (on-screen)
  2391. * @param y defines the y coordinate of the origin (on-screen)
  2392. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2393. * @param camera defines the camera to use for the picking
  2394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2395. * @returns a Ray
  2396. */
  2397. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2398. /**
  2399. * Creates a ray that can be used to pick in the scene
  2400. * @param x defines the x coordinate of the origin (on-screen)
  2401. * @param y defines the y coordinate of the origin (on-screen)
  2402. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2403. * @param result defines the ray where to store the picking ray
  2404. * @param camera defines the camera to use for the picking
  2405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2406. * @returns the current scene
  2407. */
  2408. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2409. /**
  2410. * Creates a ray that can be used to pick in the scene
  2411. * @param x defines the x coordinate of the origin (on-screen)
  2412. * @param y defines the y coordinate of the origin (on-screen)
  2413. * @param camera defines the camera to use for the picking
  2414. * @returns a Ray
  2415. */
  2416. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2417. /**
  2418. * Creates a ray that can be used to pick in the scene
  2419. * @param x defines the x coordinate of the origin (on-screen)
  2420. * @param y defines the y coordinate of the origin (on-screen)
  2421. * @param result defines the ray where to store the picking ray
  2422. * @param camera defines the camera to use for the picking
  2423. * @returns the current scene
  2424. */
  2425. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2426. private _internalPick(rayFunction, predicate?, fastCheck?);
  2427. private _internalMultiPick(rayFunction, predicate?);
  2428. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2429. private _tempPickingRay;
  2430. /** Launch a ray to try to pick a mesh in the scene
  2431. * @param x position on screen
  2432. * @param y position on screen
  2433. * @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
  2434. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2435. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2436. * @returns a PickingInfo
  2437. */
  2438. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2439. /** Launch a ray to try to pick a sprite in the scene
  2440. * @param x position on screen
  2441. * @param y position on screen
  2442. * @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
  2443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2445. * @returns a PickingInfo
  2446. */
  2447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2448. private _cachedRayForTransform;
  2449. /** Use the given ray to pick a mesh in the scene
  2450. * @param ray The ray to use to pick meshes
  2451. * @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
  2452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2453. * @returns a PickingInfo
  2454. */
  2455. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2456. /**
  2457. * Launch a ray to try to pick a mesh in the scene
  2458. * @param x X position on screen
  2459. * @param y Y position on screen
  2460. * @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
  2461. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2462. * @returns an array of PickingInfo
  2463. */
  2464. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2465. /**
  2466. * Launch a ray to try to pick a mesh in the scene
  2467. * @param ray Ray to use
  2468. * @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
  2469. * @returns an array of PickingInfo
  2470. */
  2471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2472. /**
  2473. * Force the value of meshUnderPointer
  2474. * @param mesh defines the mesh to use
  2475. */
  2476. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2477. /**
  2478. * Gets the mesh under the pointer
  2479. * @returns a Mesh or null if no mesh is under the pointer
  2480. */
  2481. getPointerOverMesh(): Nullable<AbstractMesh>;
  2482. /**
  2483. * Force the sprite under the pointer
  2484. * @param sprite defines the sprite to use
  2485. */
  2486. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2487. /**
  2488. * Gets the sprite under the pointer
  2489. * @returns a Sprite or null if no sprite is under the pointer
  2490. */
  2491. getPointerOverSprite(): Nullable<Sprite>;
  2492. /**
  2493. * Gets the current physics engine
  2494. * @returns a PhysicsEngine or null if none attached
  2495. */
  2496. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2497. /**
  2498. * Enables physics to the current scene
  2499. * @param gravity defines the scene's gravity for the physics engine
  2500. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2501. * @return a boolean indicating if the physics engine was initialized
  2502. */
  2503. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2504. /**
  2505. * Disables and disposes the physics engine associated with the scene
  2506. */
  2507. disablePhysicsEngine(): void;
  2508. /**
  2509. * Gets a boolean indicating if there is an active physics engine
  2510. * @returns a boolean indicating if there is an active physics engine
  2511. */
  2512. isPhysicsEnabled(): boolean;
  2513. /**
  2514. * Deletes a physics compound impostor
  2515. * @param compound defines the compound to delete
  2516. */
  2517. deleteCompoundImpostor(compound: any): void;
  2518. /** @hidden */
  2519. _rebuildGeometries(): void;
  2520. /** @hidden */
  2521. _rebuildTextures(): void;
  2522. /**
  2523. * Creates a default light for the scene.
  2524. * @param replace Whether to replace the existing lights in the scene.
  2525. */
  2526. createDefaultLight(replace?: boolean): void;
  2527. /**
  2528. * Creates a default camera for the scene.
  2529. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2530. * @param replace Whether to replace the existing active camera in the scene.
  2531. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2532. */
  2533. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2534. /**
  2535. * Creates a default camera and a default light
  2536. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2537. * @param replace defines if the camera and/or light will replace the existing ones
  2538. * @param attachCameraControls defines if attachControl will be called on the new camera
  2539. */
  2540. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2541. /**
  2542. * Creates a new sky box
  2543. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2544. * @param environmentTexture defines the texture to use as environment texture
  2545. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2546. * @param scale defines the overall scale of the skybox
  2547. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2548. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2549. * @returns a new mesh holding the sky box
  2550. */
  2551. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2552. /**
  2553. * Creates a new environment
  2554. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2555. * @param options defines the options you can use to configure the environment
  2556. * @returns the new EnvironmentHelper
  2557. */
  2558. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2559. /**
  2560. * Creates a new VREXperienceHelper
  2561. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2562. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2563. * @returns a new VREXperienceHelper
  2564. */
  2565. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2566. private _getByTags(list, tagsQuery, forEach?);
  2567. /**
  2568. * Get a list of meshes by tags
  2569. * @param tagsQuery defines the tags query to use
  2570. * @param forEach defines a predicate used to filter results
  2571. * @returns an array of Mesh
  2572. */
  2573. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2574. /**
  2575. * Get a list of cameras by tags
  2576. * @param tagsQuery defines the tags query to use
  2577. * @param forEach defines a predicate used to filter results
  2578. * @returns an array of Camera
  2579. */
  2580. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2581. /**
  2582. * Get a list of lights by tags
  2583. * @param tagsQuery defines the tags query to use
  2584. * @param forEach defines a predicate used to filter results
  2585. * @returns an array of Light
  2586. */
  2587. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2588. /**
  2589. * Get a list of materials by tags
  2590. * @param tagsQuery defines the tags query to use
  2591. * @param forEach defines a predicate used to filter results
  2592. * @returns an array of Material
  2593. */
  2594. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2595. /**
  2596. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2597. * This allowed control for front to back rendering or reversly depending of the special needs.
  2598. *
  2599. * @param renderingGroupId The rendering group id corresponding to its index
  2600. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2601. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2602. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2603. */
  2604. 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;
  2605. /**
  2606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2607. *
  2608. * @param renderingGroupId The rendering group id corresponding to its index
  2609. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2610. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2611. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2612. */
  2613. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2614. /**
  2615. * Will flag all materials as dirty to trigger new shader compilation
  2616. * @param flag defines the flag used to specify which material part must be marked as dirty
  2617. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2618. */
  2619. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2620. /** @hidden */
  2621. _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;
  2622. /** @hidden */
  2623. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2624. }
  2625. }
  2626. declare module BABYLON {
  2627. type Nullable<T> = T | null;
  2628. type float = number;
  2629. type double = number;
  2630. type int = number;
  2631. type FloatArray = number[] | Float32Array;
  2632. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2633. /**
  2634. * Alias for types that can be used by a Buffer or VertexBuffer.
  2635. */
  2636. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2637. }
  2638. declare module BABYLON {
  2639. /**
  2640. * The action to be carried out following a trigger
  2641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2642. */
  2643. class Action {
  2644. /** the trigger, with or without parameters, for the action */
  2645. triggerOptions: any;
  2646. /**
  2647. * Trigger for the action
  2648. */
  2649. trigger: number;
  2650. /**
  2651. * Internal only - manager for action
  2652. * @hidden
  2653. */
  2654. _actionManager: ActionManager;
  2655. private _nextActiveAction;
  2656. private _child;
  2657. private _condition?;
  2658. private _triggerParameter;
  2659. /**
  2660. * An event triggered prior to action being executed.
  2661. */
  2662. onBeforeExecuteObservable: Observable<Action>;
  2663. /**
  2664. * Creates a new Action
  2665. * @param triggerOptions the trigger, with or without parameters, for the action
  2666. * @param condition an optional determinant of action
  2667. */
  2668. constructor(
  2669. /** the trigger, with or without parameters, for the action */
  2670. triggerOptions: any, condition?: Condition);
  2671. /**
  2672. * Internal only
  2673. * @hidden
  2674. */
  2675. _prepare(): void;
  2676. /**
  2677. * Gets the trigger parameters
  2678. * @returns the trigger parameters
  2679. */
  2680. getTriggerParameter(): any;
  2681. /**
  2682. * Internal only - executes current action event
  2683. * @hidden
  2684. */
  2685. _executeCurrent(evt?: ActionEvent): void;
  2686. /**
  2687. * Execute placeholder for child classes
  2688. * @param evt optional action event
  2689. */
  2690. execute(evt?: ActionEvent): void;
  2691. /**
  2692. * Skips to next active action
  2693. */
  2694. skipToNextActiveAction(): void;
  2695. /**
  2696. * Adds action to chain of actions, may be a DoNothingAction
  2697. * @param action defines the next action to execute
  2698. * @returns The action passed in
  2699. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2700. */
  2701. then(action: Action): Action;
  2702. /**
  2703. * Internal only
  2704. * @hidden
  2705. */
  2706. _getProperty(propertyPath: string): string;
  2707. /**
  2708. * Internal only
  2709. * @hidden
  2710. */
  2711. _getEffectiveTarget(target: any, propertyPath: string): any;
  2712. /**
  2713. * Serialize placeholder for child classes
  2714. * @param parent of child
  2715. * @returns the serialized object
  2716. */
  2717. serialize(parent: any): any;
  2718. /**
  2719. * Internal only called by serialize
  2720. * @hidden
  2721. */
  2722. protected _serialize(serializedAction: any, parent?: any): any;
  2723. /**
  2724. * Internal only
  2725. * @hidden
  2726. */
  2727. static _SerializeValueAsString: (value: any) => string;
  2728. /**
  2729. * Internal only
  2730. * @hidden
  2731. */
  2732. static _GetTargetProperty: (target: Scene | Node) => {
  2733. name: string;
  2734. targetType: string;
  2735. value: string;
  2736. };
  2737. }
  2738. }
  2739. declare module BABYLON {
  2740. /**
  2741. * ActionEvent is the event being sent when an action is triggered.
  2742. */
  2743. class ActionEvent {
  2744. /** The mesh or sprite that triggered the action */
  2745. source: any;
  2746. /** The X mouse cursor position at the time of the event */
  2747. pointerX: number;
  2748. /** The Y mouse cursor position at the time of the event */
  2749. pointerY: number;
  2750. /** The mesh that is currently pointed at (can be null) */
  2751. meshUnderPointer: Nullable<AbstractMesh>;
  2752. /** the original (browser) event that triggered the ActionEvent */
  2753. sourceEvent: any;
  2754. /** additional data for the event */
  2755. additionalData: any;
  2756. /**
  2757. * Creates a new ActionEvent
  2758. * @param source The mesh or sprite that triggered the action
  2759. * @param pointerX The X mouse cursor position at the time of the event
  2760. * @param pointerY The Y mouse cursor position at the time of the event
  2761. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2762. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2763. * @param additionalData additional data for the event
  2764. */
  2765. constructor(
  2766. /** The mesh or sprite that triggered the action */
  2767. source: any,
  2768. /** The X mouse cursor position at the time of the event */
  2769. pointerX: number,
  2770. /** The Y mouse cursor position at the time of the event */
  2771. pointerY: number,
  2772. /** The mesh that is currently pointed at (can be null) */
  2773. meshUnderPointer: Nullable<AbstractMesh>,
  2774. /** the original (browser) event that triggered the ActionEvent */
  2775. sourceEvent?: any,
  2776. /** additional data for the event */
  2777. additionalData?: any);
  2778. /**
  2779. * Helper function to auto-create an ActionEvent from a source mesh.
  2780. * @param source The source mesh that triggered the event
  2781. * @param evt The original (browser) event
  2782. * @param additionalData additional data for the event
  2783. * @returns the new ActionEvent
  2784. */
  2785. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2786. /**
  2787. * Helper function to auto-create an ActionEvent from a source sprite
  2788. * @param source The source sprite that triggered the event
  2789. * @param scene Scene associated with the sprite
  2790. * @param evt The original (browser) event
  2791. * @param additionalData additional data for the event
  2792. * @returns the new ActionEvent
  2793. */
  2794. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2795. /**
  2796. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2797. * @param scene the scene where the event occurred
  2798. * @param evt The original (browser) event
  2799. * @returns the new ActionEvent
  2800. */
  2801. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2802. /**
  2803. * Helper function to auto-create an ActionEvent from a primitive
  2804. * @param prim defines the target primitive
  2805. * @param pointerPos defines the pointer position
  2806. * @param evt The original (browser) event
  2807. * @param additionalData additional data for the event
  2808. * @returns the new ActionEvent
  2809. */
  2810. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2811. }
  2812. /**
  2813. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2814. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2816. */
  2817. class ActionManager {
  2818. private static _NothingTrigger;
  2819. private static _OnPickTrigger;
  2820. private static _OnLeftPickTrigger;
  2821. private static _OnRightPickTrigger;
  2822. private static _OnCenterPickTrigger;
  2823. private static _OnPickDownTrigger;
  2824. private static _OnDoublePickTrigger;
  2825. private static _OnPickUpTrigger;
  2826. private static _OnLongPressTrigger;
  2827. private static _OnPointerOverTrigger;
  2828. private static _OnPointerOutTrigger;
  2829. private static _OnEveryFrameTrigger;
  2830. private static _OnIntersectionEnterTrigger;
  2831. private static _OnIntersectionExitTrigger;
  2832. private static _OnKeyDownTrigger;
  2833. private static _OnKeyUpTrigger;
  2834. private static _OnPickOutTrigger;
  2835. /**
  2836. * Nothing
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly NothingTrigger: number;
  2840. /**
  2841. * On pick
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnPickTrigger: number;
  2845. /**
  2846. * On left pick
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnLeftPickTrigger: number;
  2850. /**
  2851. * On right pick
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnRightPickTrigger: number;
  2855. /**
  2856. * On center pick
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnCenterPickTrigger: number;
  2860. /**
  2861. * On pick down
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnPickDownTrigger: number;
  2865. /**
  2866. * On double pick
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnDoublePickTrigger: number;
  2870. /**
  2871. * On pick up
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnPickUpTrigger: number;
  2875. /**
  2876. * On pick out.
  2877. * This trigger will only be raised if you also declared a OnPickDown
  2878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2879. */
  2880. static readonly OnPickOutTrigger: number;
  2881. /**
  2882. * On long press
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2884. */
  2885. static readonly OnLongPressTrigger: number;
  2886. /**
  2887. * On pointer over
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2889. */
  2890. static readonly OnPointerOverTrigger: number;
  2891. /**
  2892. * On pointer out
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2894. */
  2895. static readonly OnPointerOutTrigger: number;
  2896. /**
  2897. * On every frame
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly OnEveryFrameTrigger: number;
  2901. /**
  2902. * On intersection enter
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnIntersectionEnterTrigger: number;
  2906. /**
  2907. * On intersection exit
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnIntersectionExitTrigger: number;
  2911. /**
  2912. * On key down
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnKeyDownTrigger: number;
  2916. /**
  2917. * On key up
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnKeyUpTrigger: number;
  2921. /** Gets the list of active triggers */
  2922. static Triggers: {
  2923. [key: string]: number;
  2924. };
  2925. /** Gets the list of actions */
  2926. actions: Action[];
  2927. /** Gets the cursor to use when hovering items */
  2928. hoverCursor: string;
  2929. private _scene;
  2930. /**
  2931. * Creates a new action manager
  2932. * @param scene defines the hosting scene
  2933. */
  2934. constructor(scene: Scene);
  2935. /**
  2936. * Releases all associated resources
  2937. */
  2938. dispose(): void;
  2939. /**
  2940. * Gets hosting scene
  2941. * @returns the hosting scene
  2942. */
  2943. getScene(): Scene;
  2944. /**
  2945. * Does this action manager handles actions of any of the given triggers
  2946. * @param triggers defines the triggers to be tested
  2947. * @return a boolean indicating whether one (or more) of the triggers is handled
  2948. */
  2949. hasSpecificTriggers(triggers: number[]): boolean;
  2950. /**
  2951. * Does this action manager handles actions of a given trigger
  2952. * @param trigger defines the trigger to be tested
  2953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2954. * @return whether the trigger is handled
  2955. */
  2956. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2957. /**
  2958. * Does this action manager has pointer triggers
  2959. */
  2960. readonly hasPointerTriggers: boolean;
  2961. /**
  2962. * Does this action manager has pick triggers
  2963. */
  2964. readonly hasPickTriggers: boolean;
  2965. /**
  2966. * Does exist one action manager with at least one trigger
  2967. **/
  2968. static readonly HasTriggers: boolean;
  2969. /**
  2970. * Does exist one action manager with at least one pick trigger
  2971. **/
  2972. static readonly HasPickTriggers: boolean;
  2973. /**
  2974. * Does exist one action manager that handles actions of a given trigger
  2975. * @param trigger defines the trigger to be tested
  2976. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2977. **/
  2978. static HasSpecificTrigger(trigger: number): boolean;
  2979. /**
  2980. * Registers an action to this action manager
  2981. * @param action defines the action to be registered
  2982. * @return the action amended (prepared) after registration
  2983. */
  2984. registerAction(action: Action): Nullable<Action>;
  2985. /**
  2986. * Unregisters an action to this action manager
  2987. * @param action defines the action to be unregistered
  2988. * @return a boolean indicating whether the action has been unregistered
  2989. */
  2990. unregisterAction(action: Action): Boolean;
  2991. /**
  2992. * Process a specific trigger
  2993. * @param trigger defines the trigger to process
  2994. * @param evt defines the event details to be processed
  2995. */
  2996. processTrigger(trigger: number, evt?: ActionEvent): void;
  2997. /** @hidden */
  2998. _getEffectiveTarget(target: any, propertyPath: string): any;
  2999. /** @hidden */
  3000. _getProperty(propertyPath: string): string;
  3001. /**
  3002. * Serialize this manager to a JSON object
  3003. * @param name defines the property name to store this manager
  3004. * @returns a JSON representation of this manager
  3005. */
  3006. serialize(name: string): any;
  3007. /**
  3008. * Creates a new ActionManager from a JSON data
  3009. * @param parsedActions defines the JSON data to read from
  3010. * @param object defines the hosting mesh
  3011. * @param scene defines the hosting scene
  3012. */
  3013. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3014. /**
  3015. * Get a trigger name by index
  3016. * @param trigger defines the trigger index
  3017. * @returns a trigger name
  3018. */
  3019. static GetTriggerName(trigger: number): string;
  3020. }
  3021. }
  3022. declare module BABYLON {
  3023. /**
  3024. * A Condition applied to an Action
  3025. */
  3026. class Condition {
  3027. /**
  3028. * Internal only - manager for action
  3029. * @hidden
  3030. */
  3031. _actionManager: ActionManager;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _evaluationId: number;
  3037. /**
  3038. * Internal only
  3039. * @hidden
  3040. */
  3041. _currentResult: boolean;
  3042. /**
  3043. * Creates a new Condition
  3044. * @param actionManager the manager of the action the condition is applied to
  3045. */
  3046. constructor(actionManager: ActionManager);
  3047. /**
  3048. * Check if the current condition is valid
  3049. * @returns a boolean
  3050. */
  3051. isValid(): boolean;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _getProperty(propertyPath: string): string;
  3057. /**
  3058. * Internal only
  3059. * @hidden
  3060. */
  3061. _getEffectiveTarget(target: any, propertyPath: string): any;
  3062. /**
  3063. * Serialize placeholder for child classes
  3064. * @returns the serialized object
  3065. */
  3066. serialize(): any;
  3067. /**
  3068. * Internal only
  3069. * @hidden
  3070. */
  3071. protected _serialize(serializedCondition: any): any;
  3072. }
  3073. /**
  3074. * Defines specific conditional operators as extensions of Condition
  3075. */
  3076. class ValueCondition extends Condition {
  3077. /** path to specify the property of the target the conditional operator uses */
  3078. propertyPath: string;
  3079. /** the value compared by the conditional operator against the current value of the property */
  3080. value: any;
  3081. /** the conditional operator, default ValueCondition.IsEqual */
  3082. operator: number;
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private static _IsEqual;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private static _IsDifferent;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsGreater;
  3098. /**
  3099. * Internal only
  3100. * @hidden
  3101. */
  3102. private static _IsLesser;
  3103. /**
  3104. * returns the number for IsEqual
  3105. */
  3106. static readonly IsEqual: number;
  3107. /**
  3108. * Returns the number for IsDifferent
  3109. */
  3110. static readonly IsDifferent: number;
  3111. /**
  3112. * Returns the number for IsGreater
  3113. */
  3114. static readonly IsGreater: number;
  3115. /**
  3116. * Returns the number for IsLesser
  3117. */
  3118. static readonly IsLesser: number;
  3119. /**
  3120. * Internal only The action manager for the condition
  3121. * @hidden
  3122. */
  3123. _actionManager: ActionManager;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. private _target;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. private _effectiveTarget;
  3134. /**
  3135. * Internal only
  3136. * @hidden
  3137. */
  3138. private _property;
  3139. /**
  3140. * Creates a new ValueCondition
  3141. * @param actionManager manager for the action the condition applies to
  3142. * @param target for the action
  3143. * @param propertyPath path to specify the property of the target the conditional operator uses
  3144. * @param value the value compared by the conditional operator against the current value of the property
  3145. * @param operator the conditional operator, default ValueCondition.IsEqual
  3146. */
  3147. constructor(actionManager: ActionManager, target: any,
  3148. /** path to specify the property of the target the conditional operator uses */
  3149. propertyPath: string,
  3150. /** the value compared by the conditional operator against the current value of the property */
  3151. value: any,
  3152. /** the conditional operator, default ValueCondition.IsEqual */
  3153. operator?: number);
  3154. /**
  3155. * Compares the given value with the property value for the specified conditional operator
  3156. * @returns the result of the comparison
  3157. */
  3158. isValid(): boolean;
  3159. /**
  3160. * Serialize the ValueCondition into a JSON compatible object
  3161. * @returns serialization object
  3162. */
  3163. serialize(): any;
  3164. /**
  3165. * Gets the name of the conditional operator for the ValueCondition
  3166. * @param operator the conditional operator
  3167. * @returns the name
  3168. */
  3169. static GetOperatorName(operator: number): string;
  3170. }
  3171. /**
  3172. * Defines a predicate condition as an extension of Condition
  3173. */
  3174. class PredicateCondition extends Condition {
  3175. /** defines the predicate function used to validate the condition */
  3176. predicate: () => boolean;
  3177. /**
  3178. * Internal only - manager for action
  3179. * @hidden
  3180. */
  3181. _actionManager: ActionManager;
  3182. /**
  3183. * Creates a new PredicateCondition
  3184. * @param actionManager manager for the action the condition applies to
  3185. * @param predicate defines the predicate function used to validate the condition
  3186. */
  3187. constructor(actionManager: ActionManager,
  3188. /** defines the predicate function used to validate the condition */
  3189. predicate: () => boolean);
  3190. /**
  3191. * @returns the validity of the predicate condition
  3192. */
  3193. isValid(): boolean;
  3194. }
  3195. /**
  3196. * Defines a state condition as an extension of Condition
  3197. */
  3198. class StateCondition extends Condition {
  3199. value: string;
  3200. /**
  3201. * Internal only - manager for action
  3202. * @hidden
  3203. */
  3204. _actionManager: ActionManager;
  3205. /**
  3206. * Internal only
  3207. * @hidden
  3208. */
  3209. private _target;
  3210. /**
  3211. * Creates a new StateCondition
  3212. * @param actionManager manager for the action the condition applies to
  3213. * @param target of the condition
  3214. * @param value to compare with target state
  3215. */
  3216. constructor(actionManager: ActionManager, target: any, value: string);
  3217. /**
  3218. * @returns the validity of the state
  3219. */
  3220. isValid(): boolean;
  3221. /**
  3222. * Serialize the StateCondition into a JSON compatible object
  3223. * @returns serialization object
  3224. */
  3225. serialize(): any;
  3226. }
  3227. }
  3228. declare module BABYLON {
  3229. class SwitchBooleanAction extends Action {
  3230. propertyPath: string;
  3231. private _target;
  3232. private _effectiveTarget;
  3233. private _property;
  3234. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3235. _prepare(): void;
  3236. execute(): void;
  3237. serialize(parent: any): any;
  3238. }
  3239. class SetStateAction extends Action {
  3240. value: string;
  3241. private _target;
  3242. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3243. execute(): void;
  3244. serialize(parent: any): any;
  3245. }
  3246. class SetValueAction extends Action {
  3247. propertyPath: string;
  3248. value: any;
  3249. private _target;
  3250. private _effectiveTarget;
  3251. private _property;
  3252. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3253. _prepare(): void;
  3254. execute(): void;
  3255. serialize(parent: any): any;
  3256. }
  3257. class IncrementValueAction extends Action {
  3258. propertyPath: string;
  3259. value: any;
  3260. private _target;
  3261. private _effectiveTarget;
  3262. private _property;
  3263. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3264. _prepare(): void;
  3265. execute(): void;
  3266. serialize(parent: any): any;
  3267. }
  3268. class PlayAnimationAction extends Action {
  3269. from: number;
  3270. to: number;
  3271. loop: boolean | undefined;
  3272. private _target;
  3273. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3274. _prepare(): void;
  3275. execute(): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. class StopAnimationAction extends Action {
  3279. private _target;
  3280. constructor(triggerOptions: any, target: any, condition?: Condition);
  3281. _prepare(): void;
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class DoNothingAction extends Action {
  3286. constructor(triggerOptions?: any, condition?: Condition);
  3287. execute(): void;
  3288. serialize(parent: any): any;
  3289. }
  3290. class CombineAction extends Action {
  3291. children: Action[];
  3292. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3293. _prepare(): void;
  3294. execute(evt: ActionEvent): void;
  3295. serialize(parent: any): any;
  3296. }
  3297. class ExecuteCodeAction extends Action {
  3298. func: (evt: ActionEvent) => void;
  3299. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3300. execute(evt: ActionEvent): void;
  3301. }
  3302. class SetParentAction extends Action {
  3303. private _parent;
  3304. private _target;
  3305. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3306. _prepare(): void;
  3307. execute(): void;
  3308. serialize(parent: any): any;
  3309. }
  3310. class PlaySoundAction extends Action {
  3311. private _sound;
  3312. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3313. _prepare(): void;
  3314. execute(): void;
  3315. serialize(parent: any): any;
  3316. }
  3317. class StopSoundAction extends Action {
  3318. private _sound;
  3319. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3320. _prepare(): void;
  3321. execute(): void;
  3322. serialize(parent: any): any;
  3323. }
  3324. }
  3325. declare module BABYLON {
  3326. class InterpolateValueAction extends Action {
  3327. propertyPath: string;
  3328. value: any;
  3329. duration: number;
  3330. stopOtherAnimations: boolean | undefined;
  3331. onInterpolationDone: (() => void) | undefined;
  3332. private _target;
  3333. private _effectiveTarget;
  3334. private _property;
  3335. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3336. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3337. _prepare(): void;
  3338. execute(): void;
  3339. serialize(parent: any): any;
  3340. }
  3341. }
  3342. declare module BABYLON {
  3343. class Animatable {
  3344. target: any;
  3345. fromFrame: number;
  3346. toFrame: number;
  3347. loopAnimation: boolean;
  3348. onAnimationEnd: (() => void) | null | undefined;
  3349. private _localDelayOffset;
  3350. private _pausedDelay;
  3351. private _runtimeAnimations;
  3352. private _paused;
  3353. private _scene;
  3354. private _speedRatio;
  3355. private _weight;
  3356. private _syncRoot;
  3357. animationStarted: boolean;
  3358. /**
  3359. * Observer raised when the animation ends
  3360. */
  3361. onAnimationEndObservable: Observable<Animatable>;
  3362. /**
  3363. * Gets the root Animatable used to synchronize and normalize animations
  3364. */
  3365. readonly syncRoot: Animatable;
  3366. /**
  3367. * Gets the current frame of the first RuntimeAnimation
  3368. * Used to synchronize Animatables
  3369. */
  3370. readonly masterFrame: number;
  3371. /**
  3372. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3373. */
  3374. weight: number;
  3375. /**
  3376. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3377. */
  3378. speedRatio: number;
  3379. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3380. /**
  3381. * Synchronize and normalize current Animatable with a source Animatable
  3382. * This is useful when using animation weights and when animations are not of the same length
  3383. * @param root defines the root Animatable to synchronize with
  3384. * @returns the current Animatable
  3385. */
  3386. syncWith(root: Animatable): Animatable;
  3387. getAnimations(): RuntimeAnimation[];
  3388. appendAnimations(target: any, animations: Animation[]): void;
  3389. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3390. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3391. reset(): void;
  3392. enableBlending(blendingSpeed: number): void;
  3393. disableBlending(): void;
  3394. goToFrame(frame: number): void;
  3395. pause(): void;
  3396. restart(): void;
  3397. private _raiseOnAnimationEnd();
  3398. stop(animationName?: string): void;
  3399. /**
  3400. * Wait asynchronously for the animation to end
  3401. * @returns a promise which will be fullfilled when the animation ends
  3402. */
  3403. waitAsync(): Promise<Animatable>;
  3404. /** @hidden */
  3405. _animate(delay: number): boolean;
  3406. }
  3407. }
  3408. declare module BABYLON {
  3409. /**
  3410. * Represents the range of an animation
  3411. */
  3412. class AnimationRange {
  3413. /**The name of the animation range**/
  3414. name: string;
  3415. /**The starting frame of the animation */
  3416. from: number;
  3417. /**The ending frame of the animation*/
  3418. to: number;
  3419. /**
  3420. * Initializes the range of an animation
  3421. * @param name The name of the animation range
  3422. * @param from The starting frame of the animation
  3423. * @param to The ending frame of the animation
  3424. */
  3425. constructor(
  3426. /**The name of the animation range**/
  3427. name: string,
  3428. /**The starting frame of the animation */
  3429. from: number,
  3430. /**The ending frame of the animation*/
  3431. to: number);
  3432. /**
  3433. * Makes a copy of the animation range
  3434. * @returns A copy of the animation range
  3435. */
  3436. clone(): AnimationRange;
  3437. }
  3438. /**
  3439. * Composed of a frame, and an action function
  3440. */
  3441. class AnimationEvent {
  3442. /** The frame for which the event is triggered **/
  3443. frame: number;
  3444. /** The event to perform when triggered **/
  3445. action: () => void;
  3446. /** Specifies if the event should be triggered only once**/
  3447. onlyOnce: boolean | undefined;
  3448. /**
  3449. * Specifies if the animation event is done
  3450. */
  3451. isDone: boolean;
  3452. /**
  3453. * Initializes the animation event
  3454. * @param frame The frame for which the event is triggered
  3455. * @param action The event to perform when triggered
  3456. * @param onlyOnce Specifies if the event should be triggered only once
  3457. */
  3458. constructor(
  3459. /** The frame for which the event is triggered **/
  3460. frame: number,
  3461. /** The event to perform when triggered **/
  3462. action: () => void,
  3463. /** Specifies if the event should be triggered only once**/
  3464. onlyOnce?: boolean | undefined);
  3465. /** @hidden */
  3466. _clone(): AnimationEvent;
  3467. }
  3468. /**
  3469. * A cursor which tracks a point on a path
  3470. */
  3471. class PathCursor {
  3472. private path;
  3473. /**
  3474. * Stores path cursor callbacks for when an onchange event is triggered
  3475. */
  3476. private _onchange;
  3477. /**
  3478. * The value of the path cursor
  3479. */
  3480. value: number;
  3481. /**
  3482. * The animation array of the path cursor
  3483. */
  3484. animations: Animation[];
  3485. /**
  3486. * Initializes the path cursor
  3487. * @param path The path to track
  3488. */
  3489. constructor(path: Path2);
  3490. /**
  3491. * Gets the cursor point on the path
  3492. * @returns A point on the path cursor at the cursor location
  3493. */
  3494. getPoint(): Vector3;
  3495. /**
  3496. * Moves the cursor ahead by the step amount
  3497. * @param step The amount to move the cursor forward
  3498. * @returns This path cursor
  3499. */
  3500. moveAhead(step?: number): PathCursor;
  3501. /**
  3502. * Moves the cursor behind by the step amount
  3503. * @param step The amount to move the cursor back
  3504. * @returns This path cursor
  3505. */
  3506. moveBack(step?: number): PathCursor;
  3507. /**
  3508. * Moves the cursor by the step amount
  3509. * If the step amount is greater than one, an exception is thrown
  3510. * @param step The amount to move the cursor
  3511. * @returns This path cursor
  3512. */
  3513. move(step: number): PathCursor;
  3514. /**
  3515. * Ensures that the value is limited between zero and one
  3516. * @returns This path cursor
  3517. */
  3518. private ensureLimits();
  3519. /**
  3520. * Runs onchange callbacks on change (used by the animation engine)
  3521. * @returns This path cursor
  3522. */
  3523. private raiseOnChange();
  3524. /**
  3525. * Executes a function on change
  3526. * @param f A path cursor onchange callback
  3527. * @returns This path cursor
  3528. */
  3529. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3530. }
  3531. /**
  3532. * Defines an interface which represents an animation key frame
  3533. */
  3534. interface IAnimationKey {
  3535. /**
  3536. * Frame of the key frame
  3537. */
  3538. frame: number;
  3539. /**
  3540. * Value at the specifies key frame
  3541. */
  3542. value: any;
  3543. /**
  3544. * The input tangent for the cubic hermite spline
  3545. */
  3546. inTangent?: any;
  3547. /**
  3548. * The output tangent for the cubic hermite spline
  3549. */
  3550. outTangent?: any;
  3551. /**
  3552. * The animation interpolation type
  3553. */
  3554. interpolation?: AnimationKeyInterpolation;
  3555. }
  3556. /**
  3557. * Enum for the animation key frame interpolation type
  3558. */
  3559. enum AnimationKeyInterpolation {
  3560. /**
  3561. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3562. */
  3563. STEP = 1,
  3564. }
  3565. /**
  3566. * Class used to store any kind of animation
  3567. */
  3568. class Animation {
  3569. /**Name of the animation */
  3570. name: string;
  3571. /**Property to animate */
  3572. targetProperty: string;
  3573. /**The frames per second of the animation */
  3574. framePerSecond: number;
  3575. /**The data type of the animation */
  3576. dataType: number;
  3577. /**The loop mode of the animation */
  3578. loopMode: number | undefined;
  3579. /**Specifies if blending should be enabled */
  3580. enableBlending: boolean | undefined;
  3581. /**
  3582. * Use matrix interpolation instead of using direct key value when animating matrices
  3583. */
  3584. static AllowMatricesInterpolation: boolean;
  3585. /**
  3586. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3587. */
  3588. static AllowMatrixDecomposeForInterpolation: boolean;
  3589. /**
  3590. * Stores the key frames of the animation
  3591. */
  3592. private _keys;
  3593. /**
  3594. * Stores the easing function of the animation
  3595. */
  3596. private _easingFunction;
  3597. /**
  3598. * @hidden Internal use only
  3599. */
  3600. _runtimeAnimations: RuntimeAnimation[];
  3601. /**
  3602. * The set of event that will be linked to this animation
  3603. */
  3604. private _events;
  3605. /**
  3606. * Stores an array of target property paths
  3607. */
  3608. targetPropertyPath: string[];
  3609. /**
  3610. * Stores the blending speed of the animation
  3611. */
  3612. blendingSpeed: number;
  3613. /**
  3614. * Stores the animation ranges for the animation
  3615. */
  3616. private _ranges;
  3617. /**
  3618. * @hidden Internal use
  3619. */
  3620. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3621. /**
  3622. * Sets up an animation
  3623. * @param property The property to animate
  3624. * @param animationType The animation type to apply
  3625. * @param framePerSecond The frames per second of the animation
  3626. * @param easingFunction The easing function used in the animation
  3627. * @returns The created animation
  3628. */
  3629. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3630. /**
  3631. * Create and start an animation on a node
  3632. * @param name defines the name of the global animation that will be run on all nodes
  3633. * @param node defines the root node where the animation will take place
  3634. * @param targetProperty defines property to animate
  3635. * @param framePerSecond defines the number of frame per second yo use
  3636. * @param totalFrame defines the number of frames in total
  3637. * @param from defines the initial value
  3638. * @param to defines the final value
  3639. * @param loopMode defines which loop mode you want to use (off by default)
  3640. * @param easingFunction defines the easing function to use (linear by default)
  3641. * @param onAnimationEnd defines the callback to call when animation end
  3642. * @returns the animatable created for this animation
  3643. */
  3644. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3645. /**
  3646. * Create and start an animation on a node and its descendants
  3647. * @param name defines the name of the global animation that will be run on all nodes
  3648. * @param node defines the root node where the animation will take place
  3649. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3650. * @param targetProperty defines property to animate
  3651. * @param framePerSecond defines the number of frame per second to use
  3652. * @param totalFrame defines the number of frames in total
  3653. * @param from defines the initial value
  3654. * @param to defines the final value
  3655. * @param loopMode defines which loop mode you want to use (off by default)
  3656. * @param easingFunction defines the easing function to use (linear by default)
  3657. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3658. * @returns the list of animatables created for all nodes
  3659. * @example https://www.babylonjs-playground.com/#MH0VLI
  3660. */
  3661. 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[]>;
  3662. /**
  3663. * Creates a new animation, merges it with the existing animations and starts it
  3664. * @param name Name of the animation
  3665. * @param node Node which contains the scene that begins the animations
  3666. * @param targetProperty Specifies which property to animate
  3667. * @param framePerSecond The frames per second of the animation
  3668. * @param totalFrame The total number of frames
  3669. * @param from The frame at the beginning of the animation
  3670. * @param to The frame at the end of the animation
  3671. * @param loopMode Specifies the loop mode of the animation
  3672. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3673. * @param onAnimationEnd Callback to run once the animation is complete
  3674. * @returns Nullable animation
  3675. */
  3676. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3677. /**
  3678. * Transition property of an host to the target Value
  3679. * @param property The property to transition
  3680. * @param targetValue The target Value of the property
  3681. * @param host The object where the property to animate belongs
  3682. * @param scene Scene used to run the animation
  3683. * @param frameRate Framerate (in frame/s) to use
  3684. * @param transition The transition type we want to use
  3685. * @param duration The duration of the animation, in milliseconds
  3686. * @param onAnimationEnd Callback trigger at the end of the animation
  3687. * @returns Nullable animation
  3688. */
  3689. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3690. /**
  3691. * Return the array of runtime animations currently using this animation
  3692. */
  3693. readonly runtimeAnimations: RuntimeAnimation[];
  3694. /**
  3695. * Specifies if any of the runtime animations are currently running
  3696. */
  3697. readonly hasRunningRuntimeAnimations: boolean;
  3698. /**
  3699. * Initializes the animation
  3700. * @param name Name of the animation
  3701. * @param targetProperty Property to animate
  3702. * @param framePerSecond The frames per second of the animation
  3703. * @param dataType The data type of the animation
  3704. * @param loopMode The loop mode of the animation
  3705. * @param enableBlendings Specifies if blending should be enabled
  3706. */
  3707. constructor(
  3708. /**Name of the animation */
  3709. name: string,
  3710. /**Property to animate */
  3711. targetProperty: string,
  3712. /**The frames per second of the animation */
  3713. framePerSecond: number,
  3714. /**The data type of the animation */
  3715. dataType: number,
  3716. /**The loop mode of the animation */
  3717. loopMode?: number | undefined,
  3718. /**Specifies if blending should be enabled */
  3719. enableBlending?: boolean | undefined);
  3720. /**
  3721. * Converts the animation to a string
  3722. * @param fullDetails support for multiple levels of logging within scene loading
  3723. * @returns String form of the animation
  3724. */
  3725. toString(fullDetails?: boolean): string;
  3726. /**
  3727. * Add an event to this animation
  3728. * @param event Event to add
  3729. */
  3730. addEvent(event: AnimationEvent): void;
  3731. /**
  3732. * Remove all events found at the given frame
  3733. * @param frame The frame to remove events from
  3734. */
  3735. removeEvents(frame: number): void;
  3736. /**
  3737. * Retrieves all the events from the animation
  3738. * @returns Events from the animation
  3739. */
  3740. getEvents(): AnimationEvent[];
  3741. /**
  3742. * Creates an animation range
  3743. * @param name Name of the animation range
  3744. * @param from Starting frame of the animation range
  3745. * @param to Ending frame of the animation
  3746. */
  3747. createRange(name: string, from: number, to: number): void;
  3748. /**
  3749. * Deletes an animation range by name
  3750. * @param name Name of the animation range to delete
  3751. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3752. */
  3753. deleteRange(name: string, deleteFrames?: boolean): void;
  3754. /**
  3755. * Gets the animation range by name, or null if not defined
  3756. * @param name Name of the animation range
  3757. * @returns Nullable animation range
  3758. */
  3759. getRange(name: string): Nullable<AnimationRange>;
  3760. /**
  3761. * Gets the key frames from the animation
  3762. * @returns The key frames of the animation
  3763. */
  3764. getKeys(): Array<IAnimationKey>;
  3765. /**
  3766. * Gets the highest frame rate of the animation
  3767. * @returns Highest frame rate of the animation
  3768. */
  3769. getHighestFrame(): number;
  3770. /**
  3771. * Gets the easing function of the animation
  3772. * @returns Easing function of the animation
  3773. */
  3774. getEasingFunction(): IEasingFunction;
  3775. /**
  3776. * Sets the easing function of the animation
  3777. * @param easingFunction A custom mathematical formula for animation
  3778. */
  3779. setEasingFunction(easingFunction: EasingFunction): void;
  3780. /**
  3781. * Interpolates a scalar linearly
  3782. * @param startValue Start value of the animation curve
  3783. * @param endValue End value of the animation curve
  3784. * @param gradient Scalar amount to interpolate
  3785. * @returns Interpolated scalar value
  3786. */
  3787. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3788. /**
  3789. * Interpolates a scalar cubically
  3790. * @param startValue Start value of the animation curve
  3791. * @param outTangent End tangent of the animation
  3792. * @param endValue End value of the animation curve
  3793. * @param inTangent Start tangent of the animation curve
  3794. * @param gradient Scalar amount to interpolate
  3795. * @returns Interpolated scalar value
  3796. */
  3797. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3798. /**
  3799. * Interpolates a quaternion using a spherical linear interpolation
  3800. * @param startValue Start value of the animation curve
  3801. * @param endValue End value of the animation curve
  3802. * @param gradient Scalar amount to interpolate
  3803. * @returns Interpolated quaternion value
  3804. */
  3805. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3806. /**
  3807. * Interpolates a quaternion cubically
  3808. * @param startValue Start value of the animation curve
  3809. * @param outTangent End tangent of the animation curve
  3810. * @param endValue End value of the animation curve
  3811. * @param inTangent Start tangent of the animation curve
  3812. * @param gradient Scalar amount to interpolate
  3813. * @returns Interpolated quaternion value
  3814. */
  3815. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3816. /**
  3817. * Interpolates a Vector3 linearl
  3818. * @param startValue Start value of the animation curve
  3819. * @param endValue End value of the animation curve
  3820. * @param gradient Scalar amount to interpolate
  3821. * @returns Interpolated scalar value
  3822. */
  3823. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3824. /**
  3825. * Interpolates a Vector3 cubically
  3826. * @param startValue Start value of the animation curve
  3827. * @param outTangent End tangent of the animation
  3828. * @param endValue End value of the animation curve
  3829. * @param inTangent Start tangent of the animation curve
  3830. * @param gradient Scalar amount to interpolate
  3831. * @returns InterpolatedVector3 value
  3832. */
  3833. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3834. /**
  3835. * Interpolates a Vector2 linearly
  3836. * @param startValue Start value of the animation curve
  3837. * @param endValue End value of the animation curve
  3838. * @param gradient Scalar amount to interpolate
  3839. * @returns Interpolated Vector2 value
  3840. */
  3841. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3842. /**
  3843. * Interpolates a Vector2 cubically
  3844. * @param startValue Start value of the animation curve
  3845. * @param outTangent End tangent of the animation
  3846. * @param endValue End value of the animation curve
  3847. * @param inTangent Start tangent of the animation curve
  3848. * @param gradient Scalar amount to interpolate
  3849. * @returns Interpolated Vector2 value
  3850. */
  3851. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3852. /**
  3853. * Interpolates a size linearly
  3854. * @param startValue Start value of the animation curve
  3855. * @param endValue End value of the animation curve
  3856. * @param gradient Scalar amount to interpolate
  3857. * @returns Interpolated Size value
  3858. */
  3859. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3860. /**
  3861. * Interpolates a Color3 linearly
  3862. * @param startValue Start value of the animation curve
  3863. * @param endValue End value of the animation curve
  3864. * @param gradient Scalar amount to interpolate
  3865. * @returns Interpolated Color3 value
  3866. */
  3867. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3868. /**
  3869. * @hidden Internal use only
  3870. */
  3871. _getKeyValue(value: any): any;
  3872. /**
  3873. * @hidden Internal use only
  3874. */
  3875. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3876. /**
  3877. * Defines the function to use to interpolate matrices
  3878. * @param startValue defines the start matrix
  3879. * @param endValue defines the end matrix
  3880. * @param gradient defines the gradient between both matrices
  3881. * @param result defines an optional target matrix where to store the interpolation
  3882. * @returns the interpolated matrix
  3883. */
  3884. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3885. /**
  3886. * Makes a copy of the animation
  3887. * @returns Cloned animation
  3888. */
  3889. clone(): Animation;
  3890. /**
  3891. * Sets the key frames of the animation
  3892. * @param values The animation key frames to set
  3893. */
  3894. setKeys(values: Array<IAnimationKey>): void;
  3895. /**
  3896. * Serializes the animation to an object
  3897. * @returns Serialized object
  3898. */
  3899. serialize(): any;
  3900. /**
  3901. * Float animation type
  3902. */
  3903. private static _ANIMATIONTYPE_FLOAT;
  3904. /**
  3905. * Vector3 animation type
  3906. */
  3907. private static _ANIMATIONTYPE_VECTOR3;
  3908. /**
  3909. * Quaternion animation type
  3910. */
  3911. private static _ANIMATIONTYPE_QUATERNION;
  3912. /**
  3913. * Matrix animation type
  3914. */
  3915. private static _ANIMATIONTYPE_MATRIX;
  3916. /**
  3917. * Color3 animation type
  3918. */
  3919. private static _ANIMATIONTYPE_COLOR3;
  3920. /**
  3921. * Vector2 animation type
  3922. */
  3923. private static _ANIMATIONTYPE_VECTOR2;
  3924. /**
  3925. * Size animation type
  3926. */
  3927. private static _ANIMATIONTYPE_SIZE;
  3928. /**
  3929. * Relative Loop Mode
  3930. */
  3931. private static _ANIMATIONLOOPMODE_RELATIVE;
  3932. /**
  3933. * Cycle Loop Mode
  3934. */
  3935. private static _ANIMATIONLOOPMODE_CYCLE;
  3936. /**
  3937. * Constant Loop Mode
  3938. */
  3939. private static _ANIMATIONLOOPMODE_CONSTANT;
  3940. /**
  3941. * Get the float animation type
  3942. */
  3943. static readonly ANIMATIONTYPE_FLOAT: number;
  3944. /**
  3945. * Get the Vector3 animation type
  3946. */
  3947. static readonly ANIMATIONTYPE_VECTOR3: number;
  3948. /**
  3949. * Get the Vectpr2 animation type
  3950. */
  3951. static readonly ANIMATIONTYPE_VECTOR2: number;
  3952. /**
  3953. * Get the Size animation type
  3954. */
  3955. static readonly ANIMATIONTYPE_SIZE: number;
  3956. /**
  3957. * Get the Quaternion animation type
  3958. */
  3959. static readonly ANIMATIONTYPE_QUATERNION: number;
  3960. /**
  3961. * Get the Matrix animation type
  3962. */
  3963. static readonly ANIMATIONTYPE_MATRIX: number;
  3964. /**
  3965. * Get the Color3 animation type
  3966. */
  3967. static readonly ANIMATIONTYPE_COLOR3: number;
  3968. /**
  3969. * Get the Relative Loop Mode
  3970. */
  3971. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3972. /**
  3973. * Get the Cycle Loop Mode
  3974. */
  3975. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3976. /**
  3977. * Get the Constant Loop Mode
  3978. */
  3979. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3980. /** @hidden */
  3981. static _UniversalLerp(left: any, right: any, amount: number): any;
  3982. /**
  3983. * Parses an animation object and creates an animation
  3984. * @param parsedAnimation Parsed animation object
  3985. * @returns Animation object
  3986. */
  3987. static Parse(parsedAnimation: any): Animation;
  3988. /**
  3989. * Appends the serialized animations from the source animations
  3990. * @param source Source containing the animations
  3991. * @param destination Target to store the animations
  3992. */
  3993. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3994. }
  3995. }
  3996. declare module BABYLON {
  3997. /**
  3998. * This class defines the direct association between an animation and a target
  3999. */
  4000. class TargetedAnimation {
  4001. animation: Animation;
  4002. target: any;
  4003. }
  4004. /**
  4005. * Use this class to create coordinated animations on multiple targets
  4006. */
  4007. class AnimationGroup implements IDisposable {
  4008. name: string;
  4009. private _scene;
  4010. private _targetedAnimations;
  4011. private _animatables;
  4012. private _from;
  4013. private _to;
  4014. private _isStarted;
  4015. private _speedRatio;
  4016. onAnimationEndObservable: Observable<TargetedAnimation>;
  4017. /**
  4018. * This observable will notify when all animations have ended.
  4019. */
  4020. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4021. /**
  4022. * Gets the first frame
  4023. */
  4024. readonly from: number;
  4025. /**
  4026. * Gets the last frame
  4027. */
  4028. readonly to: number;
  4029. /**
  4030. * Define if the animations are started
  4031. */
  4032. readonly isStarted: boolean;
  4033. /**
  4034. * Gets or sets the speed ratio to use for all animations
  4035. */
  4036. /**
  4037. * Gets or sets the speed ratio to use for all animations
  4038. */
  4039. speedRatio: number;
  4040. /**
  4041. * Gets the targeted animations for this animation group
  4042. */
  4043. readonly targetedAnimations: Array<TargetedAnimation>;
  4044. /**
  4045. * returning the list of animatables controlled by this animation group.
  4046. */
  4047. readonly animatables: Array<Animatable>;
  4048. constructor(name: string, scene?: Nullable<Scene>);
  4049. /**
  4050. * Add an animation (with its target) in the group
  4051. * @param animation defines the animation we want to add
  4052. * @param target defines the target of the animation
  4053. * @returns the {BABYLON.TargetedAnimation} object
  4054. */
  4055. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4056. /**
  4057. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4058. * It can add constant keys at begin or end
  4059. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4060. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4061. */
  4062. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4063. /**
  4064. * Start all animations on given targets
  4065. * @param loop defines if animations must loop
  4066. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4067. * @param from defines the from key (optional)
  4068. * @param to defines the to key (optional)
  4069. * @returns the current animation group
  4070. */
  4071. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4072. /**
  4073. * Pause all animations
  4074. */
  4075. pause(): AnimationGroup;
  4076. /**
  4077. * Play all animations to initial state
  4078. * This function will start() the animations if they were not started or will restart() them if they were paused
  4079. * @param loop defines if animations must loop
  4080. */
  4081. play(loop?: boolean): AnimationGroup;
  4082. /**
  4083. * Reset all animations to initial state
  4084. */
  4085. reset(): AnimationGroup;
  4086. /**
  4087. * Restart animations from key 0
  4088. */
  4089. restart(): AnimationGroup;
  4090. /**
  4091. * Stop all animations
  4092. */
  4093. stop(): AnimationGroup;
  4094. /**
  4095. * Set animation weight for all animatables
  4096. * @param weight defines the weight to use
  4097. * @return the animationGroup
  4098. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4099. */
  4100. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4101. /**
  4102. * Synchronize and normalize all animatables with a source animatable
  4103. * @param root defines the root animatable to synchronize with
  4104. * @return the animationGroup
  4105. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4106. */
  4107. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4108. /**
  4109. * Goes to a specific frame in this animation group
  4110. * @param frame the frame number to go to
  4111. * @return the animationGroup
  4112. */
  4113. goToFrame(frame: number): AnimationGroup;
  4114. /**
  4115. * Dispose all associated resources
  4116. */
  4117. dispose(): void;
  4118. private _checkAnimationGroupEnded(animatable);
  4119. }
  4120. }
  4121. declare module BABYLON {
  4122. /**
  4123. * Class used to override all child animations of a given target
  4124. */
  4125. class AnimationPropertiesOverride {
  4126. /**
  4127. * Gets or sets a value indicating if animation blending must be used
  4128. */
  4129. enableBlending: boolean;
  4130. /**
  4131. * Gets or sets the blending speed to use when enableBlending is true
  4132. */
  4133. blendingSpeed: number;
  4134. /**
  4135. * Gets or sets the default loop mode to use
  4136. */
  4137. loopMode: number;
  4138. }
  4139. }
  4140. declare module BABYLON {
  4141. interface IEasingFunction {
  4142. ease(gradient: number): number;
  4143. }
  4144. class EasingFunction implements IEasingFunction {
  4145. private static _EASINGMODE_EASEIN;
  4146. private static _EASINGMODE_EASEOUT;
  4147. private static _EASINGMODE_EASEINOUT;
  4148. static readonly EASINGMODE_EASEIN: number;
  4149. static readonly EASINGMODE_EASEOUT: number;
  4150. static readonly EASINGMODE_EASEINOUT: number;
  4151. private _easingMode;
  4152. setEasingMode(easingMode: number): void;
  4153. getEasingMode(): number;
  4154. easeInCore(gradient: number): number;
  4155. ease(gradient: number): number;
  4156. }
  4157. class CircleEase extends EasingFunction implements IEasingFunction {
  4158. easeInCore(gradient: number): number;
  4159. }
  4160. class BackEase extends EasingFunction implements IEasingFunction {
  4161. amplitude: number;
  4162. constructor(amplitude?: number);
  4163. easeInCore(gradient: number): number;
  4164. }
  4165. class BounceEase extends EasingFunction implements IEasingFunction {
  4166. bounces: number;
  4167. bounciness: number;
  4168. constructor(bounces?: number, bounciness?: number);
  4169. easeInCore(gradient: number): number;
  4170. }
  4171. class CubicEase extends EasingFunction implements IEasingFunction {
  4172. easeInCore(gradient: number): number;
  4173. }
  4174. class ElasticEase extends EasingFunction implements IEasingFunction {
  4175. oscillations: number;
  4176. springiness: number;
  4177. constructor(oscillations?: number, springiness?: number);
  4178. easeInCore(gradient: number): number;
  4179. }
  4180. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4181. exponent: number;
  4182. constructor(exponent?: number);
  4183. easeInCore(gradient: number): number;
  4184. }
  4185. class PowerEase extends EasingFunction implements IEasingFunction {
  4186. power: number;
  4187. constructor(power?: number);
  4188. easeInCore(gradient: number): number;
  4189. }
  4190. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4191. easeInCore(gradient: number): number;
  4192. }
  4193. class QuarticEase extends EasingFunction implements IEasingFunction {
  4194. easeInCore(gradient: number): number;
  4195. }
  4196. class QuinticEase extends EasingFunction implements IEasingFunction {
  4197. easeInCore(gradient: number): number;
  4198. }
  4199. class SineEase extends EasingFunction implements IEasingFunction {
  4200. easeInCore(gradient: number): number;
  4201. }
  4202. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4203. x1: number;
  4204. y1: number;
  4205. x2: number;
  4206. y2: number;
  4207. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4208. easeInCore(gradient: number): number;
  4209. }
  4210. }
  4211. declare module BABYLON {
  4212. /**
  4213. * Defines a runtime animation
  4214. */
  4215. class RuntimeAnimation {
  4216. private _events;
  4217. /**
  4218. * The current frame of the runtime animation
  4219. */
  4220. private _currentFrame;
  4221. /**
  4222. * The animation used by the runtime animation
  4223. */
  4224. private _animation;
  4225. /**
  4226. * The target of the runtime animation
  4227. */
  4228. private _target;
  4229. /**
  4230. * The initiating animatable
  4231. */
  4232. private _host;
  4233. /**
  4234. * The original value of the runtime animation
  4235. */
  4236. private _originalValue;
  4237. /**
  4238. * The original blend value of the runtime animation
  4239. */
  4240. private _originalBlendValue;
  4241. /**
  4242. * The offsets cache of the runtime animation
  4243. */
  4244. private _offsetsCache;
  4245. /**
  4246. * The high limits cache of the runtime animation
  4247. */
  4248. private _highLimitsCache;
  4249. /**
  4250. * Specifies if the runtime animation has been stopped
  4251. */
  4252. private _stopped;
  4253. /**
  4254. * The blending factor of the runtime animation
  4255. */
  4256. private _blendingFactor;
  4257. /**
  4258. * The BabylonJS scene
  4259. */
  4260. private _scene;
  4261. /**
  4262. * The current value of the runtime animation
  4263. */
  4264. private _currentValue;
  4265. /** @hidden */
  4266. _workValue: any;
  4267. /**
  4268. * The active target of the runtime animation
  4269. */
  4270. private _activeTarget;
  4271. /**
  4272. * The target path of the runtime animation
  4273. */
  4274. private _targetPath;
  4275. /**
  4276. * The weight of the runtime animation
  4277. */
  4278. private _weight;
  4279. /**
  4280. * The ratio offset of the runtime animation
  4281. */
  4282. private _ratioOffset;
  4283. /**
  4284. * The previous delay of the runtime animation
  4285. */
  4286. private _previousDelay;
  4287. /**
  4288. * The previous ratio of the runtime animation
  4289. */
  4290. private _previousRatio;
  4291. /**
  4292. * Gets the current frame of the runtime animation
  4293. */
  4294. readonly currentFrame: number;
  4295. /**
  4296. * Gets the weight of the runtime animation
  4297. */
  4298. readonly weight: number;
  4299. /**
  4300. * Gets the current value of the runtime animation
  4301. */
  4302. readonly currentValue: any;
  4303. /**
  4304. * Gets the target path of the runtime animation
  4305. */
  4306. readonly targetPath: string;
  4307. /**
  4308. * Gets the actual target of the runtime animation
  4309. */
  4310. readonly target: any;
  4311. /**
  4312. * Create a new RuntimeAnimation object
  4313. * @param target defines the target of the animation
  4314. * @param animation defines the source animation object
  4315. * @param scene defines the hosting scene
  4316. * @param host defines the initiating Animatable
  4317. */
  4318. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4319. /**
  4320. * Gets the animation from the runtime animation
  4321. */
  4322. readonly animation: Animation;
  4323. /**
  4324. * Resets the runtime animation to the beginning
  4325. * @param restoreOriginal defines whether to restore the target property to the original value
  4326. */
  4327. reset(restoreOriginal?: boolean): void;
  4328. /**
  4329. * Specifies if the runtime animation is stopped
  4330. * @returns Boolean specifying if the runtime animation is stopped
  4331. */
  4332. isStopped(): boolean;
  4333. /**
  4334. * Disposes of the runtime animation
  4335. */
  4336. dispose(): void;
  4337. /**
  4338. * Interpolates the animation from the current frame
  4339. * @param currentFrame The frame to interpolate the animation to
  4340. * @param repeatCount The number of times that the animation should loop
  4341. * @param loopMode The type of looping mode to use
  4342. * @param offsetValue Animation offset value
  4343. * @param highLimitValue The high limit value
  4344. * @returns The interpolated value
  4345. */
  4346. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4347. /**
  4348. * Apply the interpolated value to the target
  4349. * @param currentValue defines the value computed by the animation
  4350. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4351. */
  4352. setValue(currentValue: any, weight?: number): void;
  4353. private _setValue(target, currentValue, weight, targetIndex?);
  4354. /**
  4355. * Gets the loop pmode of the runtime animation
  4356. * @returns Loop Mode
  4357. */
  4358. private _getCorrectLoopMode();
  4359. /**
  4360. * Move the current animation to a given frame
  4361. * @param frame defines the frame to move to
  4362. */
  4363. goToFrame(frame: number): void;
  4364. /**
  4365. * @hidden Internal use only
  4366. */
  4367. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4368. /**
  4369. * Execute the current animation
  4370. * @param delay defines the delay to add to the current frame
  4371. * @param from defines the lower bound of the animation range
  4372. * @param to defines the upper bound of the animation range
  4373. * @param loop defines if the current animation must loop
  4374. * @param speedRatio defines the current speed ratio
  4375. * @param weight defines the weight of the animation (default is -1 so no weight)
  4376. * @returns a boolean indicating if the animation has ended
  4377. */
  4378. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4379. }
  4380. }
  4381. declare module BABYLON {
  4382. /**
  4383. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4385. */
  4386. class Analyser {
  4387. /**
  4388. * Gets or sets the smoothing
  4389. * @ignorenaming
  4390. */
  4391. SMOOTHING: number;
  4392. /**
  4393. * Gets or sets the FFT table size
  4394. * @ignorenaming
  4395. */
  4396. FFT_SIZE: number;
  4397. /**
  4398. * Gets or sets the bar graph amplitude
  4399. * @ignorenaming
  4400. */
  4401. BARGRAPHAMPLITUDE: number;
  4402. /**
  4403. * Gets or sets the position of the debug canvas
  4404. * @ignorenaming
  4405. */
  4406. DEBUGCANVASPOS: {
  4407. x: number;
  4408. y: number;
  4409. };
  4410. /**
  4411. * Gets or sets the debug canvas size
  4412. * @ignorenaming
  4413. */
  4414. DEBUGCANVASSIZE: {
  4415. width: number;
  4416. height: number;
  4417. };
  4418. private _byteFreqs;
  4419. private _byteTime;
  4420. private _floatFreqs;
  4421. private _webAudioAnalyser;
  4422. private _debugCanvas;
  4423. private _debugCanvasContext;
  4424. private _scene;
  4425. private _registerFunc;
  4426. private _audioEngine;
  4427. /**
  4428. * Creates a new analyser
  4429. * @param scene defines hosting scene
  4430. */
  4431. constructor(scene: Scene);
  4432. /**
  4433. * Get the number of data values you will have to play with for the visualization
  4434. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4435. * @returns a number
  4436. */
  4437. getFrequencyBinCount(): number;
  4438. /**
  4439. * Gets the current frequency data as a byte array
  4440. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4441. * @returns a Uint8Array
  4442. */
  4443. getByteFrequencyData(): Uint8Array;
  4444. /**
  4445. * Gets the current waveform as a byte array
  4446. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4447. * @returns a Uint8Array
  4448. */
  4449. getByteTimeDomainData(): Uint8Array;
  4450. /**
  4451. * Gets the current frequency data as a float array
  4452. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4453. * @returns a Float32Array
  4454. */
  4455. getFloatFrequencyData(): Float32Array;
  4456. /**
  4457. * Renders the debug canvas
  4458. */
  4459. drawDebugCanvas(): void;
  4460. /**
  4461. * Stops rendering the debug canvas and removes it
  4462. */
  4463. stopDebugCanvas(): void;
  4464. /**
  4465. * Connects two audio nodes
  4466. * @param inputAudioNode defines first node to connect
  4467. * @param outputAudioNode defines second node to connect
  4468. */
  4469. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4470. /**
  4471. * Releases all associated resources
  4472. */
  4473. dispose(): void;
  4474. }
  4475. }
  4476. declare module BABYLON {
  4477. class AudioEngine {
  4478. private _audioContext;
  4479. private _audioContextInitialized;
  4480. canUseWebAudio: boolean;
  4481. masterGain: GainNode;
  4482. private _connectedAnalyser;
  4483. WarnedWebAudioUnsupported: boolean;
  4484. unlocked: boolean;
  4485. onAudioUnlocked: () => any;
  4486. isMP3supported: boolean;
  4487. isOGGsupported: boolean;
  4488. readonly audioContext: Nullable<AudioContext>;
  4489. constructor();
  4490. private _unlockiOSaudio();
  4491. private _initializeAudioContext();
  4492. dispose(): void;
  4493. getGlobalVolume(): number;
  4494. setGlobalVolume(newVolume: number): void;
  4495. connectToAnalyser(analyser: Analyser): void;
  4496. }
  4497. }
  4498. declare module BABYLON {
  4499. class Sound {
  4500. name: string;
  4501. autoplay: boolean;
  4502. loop: boolean;
  4503. useCustomAttenuation: boolean;
  4504. soundTrackId: number;
  4505. spatialSound: boolean;
  4506. refDistance: number;
  4507. rolloffFactor: number;
  4508. maxDistance: number;
  4509. distanceModel: string;
  4510. private _panningModel;
  4511. onended: () => any;
  4512. private _playbackRate;
  4513. private _streaming;
  4514. private _startTime;
  4515. private _startOffset;
  4516. private _position;
  4517. private _localDirection;
  4518. private _volume;
  4519. private _isReadyToPlay;
  4520. isPlaying: boolean;
  4521. isPaused: boolean;
  4522. private _isDirectional;
  4523. private _readyToPlayCallback;
  4524. private _audioBuffer;
  4525. private _soundSource;
  4526. private _streamingSource;
  4527. private _soundPanner;
  4528. private _soundGain;
  4529. private _inputAudioNode;
  4530. private _ouputAudioNode;
  4531. private _coneInnerAngle;
  4532. private _coneOuterAngle;
  4533. private _coneOuterGain;
  4534. private _scene;
  4535. private _connectedMesh;
  4536. private _customAttenuationFunction;
  4537. private _registerFunc;
  4538. private _isOutputConnected;
  4539. private _htmlAudioElement;
  4540. private _urlType;
  4541. /**
  4542. * Create a sound and attach it to a scene
  4543. * @param name Name of your sound
  4544. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  4545. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4546. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4547. */
  4548. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4549. dispose(): void;
  4550. isReady(): boolean;
  4551. private _soundLoaded(audioData);
  4552. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4553. updateOptions(options: any): void;
  4554. private _createSpatialParameters();
  4555. private _updateSpatialParameters();
  4556. switchPanningModelToHRTF(): void;
  4557. switchPanningModelToEqualPower(): void;
  4558. private _switchPanningModel();
  4559. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4560. /**
  4561. * Transform this sound into a directional source
  4562. * @param coneInnerAngle Size of the inner cone in degree
  4563. * @param coneOuterAngle Size of the outer cone in degree
  4564. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4565. */
  4566. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4567. setPosition(newPosition: Vector3): void;
  4568. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4569. private _updateDirection();
  4570. updateDistanceFromListener(): void;
  4571. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4572. /**
  4573. * Play the sound
  4574. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4575. * @param offset (optional) Start the sound setting it at a specific time
  4576. */
  4577. play(time?: number, offset?: number): void;
  4578. private _onended();
  4579. /**
  4580. * Stop the sound
  4581. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4582. */
  4583. stop(time?: number): void;
  4584. pause(): void;
  4585. setVolume(newVolume: number, time?: number): void;
  4586. setPlaybackRate(newPlaybackRate: number): void;
  4587. getVolume(): number;
  4588. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4589. detachFromMesh(): void;
  4590. private _onRegisterAfterWorldMatrixUpdate(node);
  4591. clone(): Nullable<Sound>;
  4592. getAudioBuffer(): AudioBuffer | null;
  4593. serialize(): any;
  4594. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4595. }
  4596. }
  4597. declare module BABYLON {
  4598. class SoundTrack {
  4599. private _outputAudioNode;
  4600. private _scene;
  4601. id: number;
  4602. soundCollection: Array<Sound>;
  4603. private _isMainTrack;
  4604. private _connectedAnalyser;
  4605. private _options;
  4606. private _isInitialized;
  4607. constructor(scene: Scene, options?: any);
  4608. private _initializeSoundTrackAudioGraph();
  4609. dispose(): void;
  4610. AddSound(sound: Sound): void;
  4611. RemoveSound(sound: Sound): void;
  4612. setVolume(newVolume: number): void;
  4613. switchPanningModelToHRTF(): void;
  4614. switchPanningModelToEqualPower(): void;
  4615. connectToAnalyser(analyser: Analyser): void;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * Interface used to define a behavior
  4621. */
  4622. interface Behavior<T> {
  4623. /** gets or sets behavior's name */
  4624. name: string;
  4625. /**
  4626. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4627. */
  4628. init(): void;
  4629. /**
  4630. * Called when the behavior is attached to a target
  4631. * @param target defines the target where the behavior is attached to
  4632. */
  4633. attach(target: T): void;
  4634. /**
  4635. * Called when the behavior is detached from its target
  4636. */
  4637. detach(): void;
  4638. }
  4639. /**
  4640. * Interface implemented by classes supporting behaviors
  4641. */
  4642. interface IBehaviorAware<T> {
  4643. /**
  4644. * Attach a behavior
  4645. * @param behavior defines the behavior to attach
  4646. * @returns the current host
  4647. */
  4648. addBehavior(behavior: Behavior<T>): T;
  4649. /**
  4650. * Remove a behavior from the current object
  4651. * @param behavior defines the behavior to detach
  4652. * @returns the current host
  4653. */
  4654. removeBehavior(behavior: Behavior<T>): T;
  4655. /**
  4656. * Gets a behavior using its name to search
  4657. * @param name defines the name to search
  4658. * @returns the behavior or null if not found
  4659. */
  4660. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4661. }
  4662. }
  4663. declare module BABYLON {
  4664. class Collider {
  4665. /** Define if a collision was found */
  4666. collisionFound: boolean;
  4667. /**
  4668. * Define last intersection point in local space
  4669. */
  4670. intersectionPoint: Vector3;
  4671. /**
  4672. * Define last collided mesh
  4673. */
  4674. collidedMesh: Nullable<AbstractMesh>;
  4675. private _collisionPoint;
  4676. private _planeIntersectionPoint;
  4677. private _tempVector;
  4678. private _tempVector2;
  4679. private _tempVector3;
  4680. private _tempVector4;
  4681. private _edge;
  4682. private _baseToVertex;
  4683. private _destinationPoint;
  4684. private _slidePlaneNormal;
  4685. private _displacementVector;
  4686. _radius: Vector3;
  4687. _retry: number;
  4688. private _velocity;
  4689. private _basePoint;
  4690. private _epsilon;
  4691. _velocityWorldLength: number;
  4692. _basePointWorld: Vector3;
  4693. private _velocityWorld;
  4694. private _normalizedVelocity;
  4695. _initialVelocity: Vector3;
  4696. _initialPosition: Vector3;
  4697. private _nearestDistance;
  4698. private _collisionMask;
  4699. collisionMask: number;
  4700. /**
  4701. * Gets the plane normal used to compute the sliding response (in local space)
  4702. */
  4703. readonly slidePlaneNormal: Vector3;
  4704. _initialize(source: Vector3, dir: Vector3, e: number): void;
  4705. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  4706. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  4707. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  4708. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  4709. _getResponse(pos: Vector3, vel: Vector3): void;
  4710. }
  4711. }
  4712. declare module BABYLON {
  4713. var CollisionWorker: string;
  4714. interface ICollisionCoordinator {
  4715. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4716. init(scene: Scene): void;
  4717. destroy(): void;
  4718. onMeshAdded(mesh: AbstractMesh): void;
  4719. onMeshUpdated(mesh: AbstractMesh): void;
  4720. onMeshRemoved(mesh: AbstractMesh): void;
  4721. onGeometryAdded(geometry: Geometry): void;
  4722. onGeometryUpdated(geometry: Geometry): void;
  4723. onGeometryDeleted(geometry: Geometry): void;
  4724. }
  4725. interface SerializedMesh {
  4726. id: string;
  4727. name: string;
  4728. uniqueId: number;
  4729. geometryId: Nullable<string>;
  4730. sphereCenter: Array<number>;
  4731. sphereRadius: number;
  4732. boxMinimum: Array<number>;
  4733. boxMaximum: Array<number>;
  4734. worldMatrixFromCache: any;
  4735. subMeshes: Array<SerializedSubMesh>;
  4736. checkCollisions: boolean;
  4737. }
  4738. interface SerializedSubMesh {
  4739. position: number;
  4740. verticesStart: number;
  4741. verticesCount: number;
  4742. indexStart: number;
  4743. indexCount: number;
  4744. hasMaterial: boolean;
  4745. sphereCenter: Array<number>;
  4746. sphereRadius: number;
  4747. boxMinimum: Array<number>;
  4748. boxMaximum: Array<number>;
  4749. }
  4750. /**
  4751. * Interface describing the value associated with a geometry
  4752. */
  4753. interface SerializedGeometry {
  4754. /**
  4755. * Defines the unique ID of the geometry
  4756. */
  4757. id: string;
  4758. /**
  4759. * Defines the array containing the positions
  4760. */
  4761. positions: Float32Array;
  4762. /**
  4763. * Defines the array containing the indices
  4764. */
  4765. indices: Uint32Array;
  4766. /**
  4767. * Defines the array containing the normals
  4768. */
  4769. normals: Float32Array;
  4770. }
  4771. interface BabylonMessage {
  4772. taskType: WorkerTaskType;
  4773. payload: InitPayload | CollidePayload | UpdatePayload;
  4774. }
  4775. interface SerializedColliderToWorker {
  4776. position: Array<number>;
  4777. velocity: Array<number>;
  4778. radius: Array<number>;
  4779. }
  4780. /** Defines supported task for worker process */
  4781. enum WorkerTaskType {
  4782. /** Initialization */
  4783. INIT = 0,
  4784. /** Update of geometry */
  4785. UPDATE = 1,
  4786. /** Evaluate collision */
  4787. COLLIDE = 2,
  4788. }
  4789. interface WorkerReply {
  4790. error: WorkerReplyType;
  4791. taskType: WorkerTaskType;
  4792. payload?: any;
  4793. }
  4794. interface CollisionReplyPayload {
  4795. newPosition: Array<number>;
  4796. collisionId: number;
  4797. collidedMeshUniqueId: number;
  4798. }
  4799. interface InitPayload {
  4800. }
  4801. interface CollidePayload {
  4802. collisionId: number;
  4803. collider: SerializedColliderToWorker;
  4804. maximumRetry: number;
  4805. excludedMeshUniqueId: Nullable<number>;
  4806. }
  4807. interface UpdatePayload {
  4808. updatedMeshes: {
  4809. [n: number]: SerializedMesh;
  4810. };
  4811. updatedGeometries: {
  4812. [s: string]: SerializedGeometry;
  4813. };
  4814. removedMeshes: Array<number>;
  4815. removedGeometries: Array<string>;
  4816. }
  4817. /** Defines kind of replies returned by worker */
  4818. enum WorkerReplyType {
  4819. /** Success */
  4820. SUCCESS = 0,
  4821. /** Unkown error */
  4822. UNKNOWN_ERROR = 1,
  4823. }
  4824. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  4825. private _scene;
  4826. private _scaledPosition;
  4827. private _scaledVelocity;
  4828. private _collisionsCallbackArray;
  4829. private _init;
  4830. private _runningUpdated;
  4831. private _worker;
  4832. private _addUpdateMeshesList;
  4833. private _addUpdateGeometriesList;
  4834. private _toRemoveMeshesArray;
  4835. private _toRemoveGeometryArray;
  4836. constructor();
  4837. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  4838. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  4839. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4840. init(scene: Scene): void;
  4841. destroy(): void;
  4842. onMeshAdded(mesh: AbstractMesh): void;
  4843. onMeshUpdated: (transformNode: TransformNode) => void;
  4844. onMeshRemoved(mesh: AbstractMesh): void;
  4845. onGeometryAdded(geometry: Geometry): void;
  4846. onGeometryUpdated: (geometry: Geometry) => void;
  4847. onGeometryDeleted(geometry: Geometry): void;
  4848. private _afterRender;
  4849. private _onMessageFromWorker;
  4850. }
  4851. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  4852. private _scene;
  4853. private _scaledPosition;
  4854. private _scaledVelocity;
  4855. private _finalPosition;
  4856. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4857. init(scene: Scene): void;
  4858. destroy(): void;
  4859. onMeshAdded(mesh: AbstractMesh): void;
  4860. onMeshUpdated(mesh: AbstractMesh): void;
  4861. onMeshRemoved(mesh: AbstractMesh): void;
  4862. onGeometryAdded(geometry: Geometry): void;
  4863. onGeometryUpdated(geometry: Geometry): void;
  4864. onGeometryDeleted(geometry: Geometry): void;
  4865. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  4866. }
  4867. }
  4868. declare function importScripts(...urls: string[]): void;
  4869. declare const safePostMessage: any;
  4870. declare module BABYLON {
  4871. var WorkerIncluded: boolean;
  4872. class CollisionCache {
  4873. private _meshes;
  4874. private _geometries;
  4875. getMeshes(): {
  4876. [n: number]: SerializedMesh;
  4877. };
  4878. getGeometries(): {
  4879. [s: number]: SerializedGeometry;
  4880. };
  4881. getMesh(id: any): SerializedMesh;
  4882. addMesh(mesh: SerializedMesh): void;
  4883. removeMesh(uniqueId: number): void;
  4884. getGeometry(id: string): SerializedGeometry;
  4885. addGeometry(geometry: SerializedGeometry): void;
  4886. removeGeometry(id: string): void;
  4887. }
  4888. class CollideWorker {
  4889. collider: Collider;
  4890. private _collisionCache;
  4891. private finalPosition;
  4892. private collisionsScalingMatrix;
  4893. private collisionTranformationMatrix;
  4894. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  4895. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  4896. private checkCollision(mesh);
  4897. private processCollisionsForSubMeshes(transformMatrix, mesh);
  4898. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  4899. private checkSubmeshCollision(subMesh);
  4900. }
  4901. interface ICollisionDetector {
  4902. onInit(payload: InitPayload): void;
  4903. onUpdate(payload: UpdatePayload): void;
  4904. onCollision(payload: CollidePayload): void;
  4905. }
  4906. class CollisionDetectorTransferable implements ICollisionDetector {
  4907. private _collisionCache;
  4908. onInit(payload: InitPayload): void;
  4909. onUpdate(payload: UpdatePayload): void;
  4910. onCollision(payload: CollidePayload): void;
  4911. }
  4912. }
  4913. declare module BABYLON {
  4914. class IntersectionInfo {
  4915. bu: Nullable<number>;
  4916. bv: Nullable<number>;
  4917. distance: number;
  4918. faceId: number;
  4919. subMeshId: number;
  4920. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  4921. }
  4922. /**
  4923. * Information about the result of picking within a scene
  4924. * See https://doc.babylonjs.com/babylon101/picking_collisions
  4925. */
  4926. class PickingInfo {
  4927. /**
  4928. * If the pick collided with an object
  4929. */
  4930. hit: boolean;
  4931. /**
  4932. * Distance away where the pick collided
  4933. */
  4934. distance: number;
  4935. /**
  4936. * The location of pick collision
  4937. */
  4938. pickedPoint: Nullable<Vector3>;
  4939. /**
  4940. * The mesh corrisponding the the pick collision
  4941. */
  4942. pickedMesh: Nullable<AbstractMesh>;
  4943. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  4944. bu: number;
  4945. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  4946. bv: number;
  4947. /** The id of the face on the mesh that was picked */
  4948. faceId: number;
  4949. /** Id of the the submesh that was picked */
  4950. subMeshId: number;
  4951. /** If a sprite was picked, this will be the sprite the pick collided with */
  4952. pickedSprite: Nullable<Sprite>;
  4953. /**
  4954. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  4955. */
  4956. originMesh: Nullable<AbstractMesh>;
  4957. /**
  4958. * The ray that was used to perform the picking.
  4959. */
  4960. ray: Nullable<Ray>;
  4961. /**
  4962. * Gets the normal corrispodning to the face the pick collided with
  4963. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  4964. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  4965. * @returns The normal corrispodning to the face the pick collided with
  4966. */
  4967. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  4968. /**
  4969. * Gets the texture coordinates of where the pick occured
  4970. * @returns the vector containing the coordnates of the texture
  4971. */
  4972. getTextureCoordinates(): Nullable<Vector2>;
  4973. }
  4974. }
  4975. declare module BABYLON {
  4976. /**
  4977. * Class used to store bone information
  4978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4979. */
  4980. class Bone extends Node {
  4981. /**
  4982. * defines the bone name
  4983. */
  4984. name: string;
  4985. private static _tmpVecs;
  4986. private static _tmpQuat;
  4987. private static _tmpMats;
  4988. /**
  4989. * Gets the list of child bones
  4990. */
  4991. children: Bone[];
  4992. /** Gets the animations associated with this bone */
  4993. animations: Animation[];
  4994. /**
  4995. * Gets or sets bone length
  4996. */
  4997. length: number;
  4998. /**
  4999. * @hidden Internal only
  5000. * Set this value to map this bone to a different index in the transform matrices
  5001. * Set this value to -1 to exclude the bone from the transform matrices
  5002. */
  5003. _index: Nullable<number>;
  5004. private _skeleton;
  5005. private _localMatrix;
  5006. private _restPose;
  5007. private _baseMatrix;
  5008. private _absoluteTransform;
  5009. private _invertedAbsoluteTransform;
  5010. private _parent;
  5011. private _scalingDeterminant;
  5012. private _worldTransform;
  5013. private _localScaling;
  5014. private _localRotation;
  5015. private _localPosition;
  5016. private _needToDecompose;
  5017. private _needToCompose;
  5018. /** @hidden */
  5019. /** @hidden */
  5020. _matrix: Matrix;
  5021. /**
  5022. * Create a new bone
  5023. * @param name defines the bone name
  5024. * @param skeleton defines the parent skeleton
  5025. * @param parentBone defines the parent (can be null if the bone is the root)
  5026. * @param localMatrix defines the local matrix
  5027. * @param restPose defines the rest pose matrix
  5028. * @param baseMatrix defines the base matrix
  5029. * @param index defines index of the bone in the hiearchy
  5030. */
  5031. constructor(
  5032. /**
  5033. * defines the bone name
  5034. */
  5035. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5036. /**
  5037. * Gets the parent skeleton
  5038. * @returns a skeleton
  5039. */
  5040. getSkeleton(): Skeleton;
  5041. /**
  5042. * Gets parent bone
  5043. * @returns a bone or null if the bone is the root of the bone hierarchy
  5044. */
  5045. getParent(): Nullable<Bone>;
  5046. /**
  5047. * Sets the parent bone
  5048. * @param parent defines the parent (can be null if the bone is the root)
  5049. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5050. */
  5051. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5052. /**
  5053. * Gets the local matrix
  5054. * @returns a matrix
  5055. */
  5056. getLocalMatrix(): Matrix;
  5057. /**
  5058. * Gets the base matrix (initial matrix which remains unchanged)
  5059. * @returns a matrix
  5060. */
  5061. getBaseMatrix(): Matrix;
  5062. /**
  5063. * Gets the rest pose matrix
  5064. * @returns a matrix
  5065. */
  5066. getRestPose(): Matrix;
  5067. /**
  5068. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5069. */
  5070. getWorldMatrix(): Matrix;
  5071. /**
  5072. * Sets the local matrix to rest pose matrix
  5073. */
  5074. returnToRest(): void;
  5075. /**
  5076. * Gets the inverse of the absolute transform matrix.
  5077. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5078. * @returns a matrix
  5079. */
  5080. getInvertedAbsoluteTransform(): Matrix;
  5081. /**
  5082. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5083. * @returns a matrix
  5084. */
  5085. getAbsoluteTransform(): Matrix;
  5086. /** Gets or sets current position (in local space) */
  5087. position: Vector3;
  5088. /** Gets or sets current rotation (in local space) */
  5089. rotation: Vector3;
  5090. /** Gets or sets current rotation quaternion (in local space) */
  5091. rotationQuaternion: Quaternion;
  5092. /** Gets or sets current scaling (in local space) */
  5093. scaling: Vector3;
  5094. /**
  5095. * Gets the animation properties override
  5096. */
  5097. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5098. private _decompose();
  5099. private _compose();
  5100. /**
  5101. * Update the base and local matrices
  5102. * @param matrix defines the new base or local matrix
  5103. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5104. * @param updateLocalMatrix defines if the local matrix should be updated
  5105. */
  5106. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5107. /** @hidden */
  5108. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5109. /**
  5110. * Flag the bone as dirty (Forcing it to update everything)
  5111. */
  5112. markAsDirty(): void;
  5113. private _markAsDirtyAndCompose();
  5114. private _markAsDirtyAndDecompose();
  5115. /**
  5116. * Copy an animation range from another bone
  5117. * @param source defines the source bone
  5118. * @param rangeName defines the range name to copy
  5119. * @param frameOffset defines the frame offset
  5120. * @param rescaleAsRequired defines if rescaling must be applied if required
  5121. * @param skelDimensionsRatio defines the scaling ratio
  5122. * @returns true if operation was successful
  5123. */
  5124. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5125. /**
  5126. * Translate the bone in local or world space
  5127. * @param vec The amount to translate the bone
  5128. * @param space The space that the translation is in
  5129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5130. */
  5131. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5132. /**
  5133. * Set the postion of the bone in local or world space
  5134. * @param position The position to set the bone
  5135. * @param space The space that the position is in
  5136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5137. */
  5138. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5139. /**
  5140. * Set the absolute position of the bone (world space)
  5141. * @param position The position to set the bone
  5142. * @param mesh The mesh that this bone is attached to
  5143. */
  5144. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5145. /**
  5146. * Scale the bone on the x, y and z axes (in local space)
  5147. * @param x The amount to scale the bone on the x axis
  5148. * @param y The amount to scale the bone on the y axis
  5149. * @param z The amount to scale the bone on the z axis
  5150. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5151. */
  5152. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5153. /**
  5154. * Set the bone scaling in local space
  5155. * @param scale defines the scaling vector
  5156. */
  5157. setScale(scale: Vector3): void;
  5158. /**
  5159. * Gets the current scaling in local space
  5160. * @returns the current scaling vector
  5161. */
  5162. getScale(): Vector3;
  5163. /**
  5164. * Gets the current scaling in local space and stores it in a target vector
  5165. * @param result defines the target vector
  5166. */
  5167. getScaleToRef(result: Vector3): void;
  5168. /**
  5169. * Set the yaw, pitch, and roll of the bone in local or world space
  5170. * @param yaw The rotation of the bone on the y axis
  5171. * @param pitch The rotation of the bone on the x axis
  5172. * @param roll The rotation of the bone on the z axis
  5173. * @param space The space that the axes of rotation are in
  5174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5175. */
  5176. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5177. /**
  5178. * Add a rotation to the bone on an axis in local or world space
  5179. * @param axis The axis to rotate the bone on
  5180. * @param amount The amount to rotate the bone
  5181. * @param space The space that the axis is in
  5182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5183. */
  5184. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5185. /**
  5186. * Set the rotation of the bone to a particular axis angle in local or world space
  5187. * @param axis The axis to rotate the bone on
  5188. * @param angle The angle that the bone should be rotated to
  5189. * @param space The space that the axis is in
  5190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5191. */
  5192. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5193. /**
  5194. * Set the euler rotation of the bone in local of world space
  5195. * @param rotation The euler rotation that the bone should be set to
  5196. * @param space The space that the rotation is in
  5197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5198. */
  5199. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5200. /**
  5201. * Set the quaternion rotation of the bone in local of world space
  5202. * @param quat The quaternion rotation that the bone should be set to
  5203. * @param space The space that the rotation is in
  5204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5205. */
  5206. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5207. /**
  5208. * Set the rotation matrix of the bone in local of world space
  5209. * @param rotMat The rotation matrix that the bone should be set to
  5210. * @param space The space that the rotation is in
  5211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5212. */
  5213. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5214. private _rotateWithMatrix(rmat, space?, mesh?);
  5215. private _getNegativeRotationToRef(rotMatInv, mesh?);
  5216. /**
  5217. * Get the position of the bone in local or world space
  5218. * @param space The space that the returned position is in
  5219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5220. * @returns The position of the bone
  5221. */
  5222. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5223. /**
  5224. * Copy the position of the bone to a vector3 in local or world space
  5225. * @param space The space that the returned position is in
  5226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5227. * @param result The vector3 to copy the position to
  5228. */
  5229. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5230. /**
  5231. * Get the absolute position of the bone (world space)
  5232. * @param mesh The mesh that this bone is attached to
  5233. * @returns The absolute position of the bone
  5234. */
  5235. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5236. /**
  5237. * Copy the absolute position of the bone (world space) to the result param
  5238. * @param mesh The mesh that this bone is attached to
  5239. * @param result The vector3 to copy the absolute position to
  5240. */
  5241. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5242. /**
  5243. * Compute the absolute transforms of this bone and its children
  5244. */
  5245. computeAbsoluteTransforms(): void;
  5246. /**
  5247. * Get the world direction from an axis that is in the local space of the bone
  5248. * @param localAxis The local direction that is used to compute the world direction
  5249. * @param mesh The mesh that this bone is attached to
  5250. * @returns The world direction
  5251. */
  5252. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5253. /**
  5254. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5255. * @param localAxis The local direction that is used to compute the world direction
  5256. * @param mesh The mesh that this bone is attached to
  5257. * @param result The vector3 that the world direction will be copied to
  5258. */
  5259. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5260. /**
  5261. * Get the euler rotation of the bone in local or world space
  5262. * @param space The space that the rotation should be in
  5263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5264. * @returns The euler rotation
  5265. */
  5266. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5267. /**
  5268. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5269. * @param space The space that the rotation should be in
  5270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5271. * @param result The vector3 that the rotation should be copied to
  5272. */
  5273. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5274. /**
  5275. * Get the quaternion rotation of the bone in either local or world space
  5276. * @param space The space that the rotation should be in
  5277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5278. * @returns The quaternion rotation
  5279. */
  5280. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5281. /**
  5282. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5283. * @param space The space that the rotation should be in
  5284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5285. * @param result The quaternion that the rotation should be copied to
  5286. */
  5287. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5288. /**
  5289. * Get the rotation matrix of the bone in local or world space
  5290. * @param space The space that the rotation should be in
  5291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5292. * @returns The rotation matrix
  5293. */
  5294. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5295. /**
  5296. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5297. * @param space The space that the rotation should be in
  5298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5299. * @param result The quaternion that the rotation should be copied to
  5300. */
  5301. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5302. /**
  5303. * Get the world position of a point that is in the local space of the bone
  5304. * @param position The local position
  5305. * @param mesh The mesh that this bone is attached to
  5306. * @returns The world position
  5307. */
  5308. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5309. /**
  5310. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5311. * @param position The local position
  5312. * @param mesh The mesh that this bone is attached to
  5313. * @param result The vector3 that the world position should be copied to
  5314. */
  5315. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5316. /**
  5317. * Get the local position of a point that is in world space
  5318. * @param position The world position
  5319. * @param mesh The mesh that this bone is attached to
  5320. * @returns The local position
  5321. */
  5322. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5323. /**
  5324. * Get the local position of a point that is in world space and copy it to the result param
  5325. * @param position The world position
  5326. * @param mesh The mesh that this bone is attached to
  5327. * @param result The vector3 that the local position should be copied to
  5328. */
  5329. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5330. }
  5331. }
  5332. declare module BABYLON {
  5333. /**
  5334. * Class used to apply inverse kinematics to bones
  5335. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5336. */
  5337. class BoneIKController {
  5338. private static _tmpVecs;
  5339. private static _tmpQuat;
  5340. private static _tmpMats;
  5341. /**
  5342. * Gets or sets the target mesh
  5343. */
  5344. targetMesh: AbstractMesh;
  5345. /** Gets or sets the mesh used as pole */
  5346. poleTargetMesh: AbstractMesh;
  5347. /**
  5348. * Gets or sets the bone used as pole
  5349. */
  5350. poleTargetBone: Nullable<Bone>;
  5351. /**
  5352. * Gets or sets the target position
  5353. */
  5354. targetPosition: Vector3;
  5355. /**
  5356. * Gets or sets the pole target position
  5357. */
  5358. poleTargetPosition: Vector3;
  5359. /**
  5360. * Gets or sets the pole target local offset
  5361. */
  5362. poleTargetLocalOffset: Vector3;
  5363. /**
  5364. * Gets or sets the pole angle
  5365. */
  5366. poleAngle: number;
  5367. /**
  5368. * Gets or sets the mesh associated with the controller
  5369. */
  5370. mesh: AbstractMesh;
  5371. /**
  5372. * 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)
  5373. */
  5374. slerpAmount: number;
  5375. private _bone1Quat;
  5376. private _bone1Mat;
  5377. private _bone2Ang;
  5378. private _bone1;
  5379. private _bone2;
  5380. private _bone1Length;
  5381. private _bone2Length;
  5382. private _maxAngle;
  5383. private _maxReach;
  5384. private _rightHandedSystem;
  5385. private _bendAxis;
  5386. private _slerping;
  5387. private _adjustRoll;
  5388. /**
  5389. * Gets or sets maximum allowed angle
  5390. */
  5391. maxAngle: number;
  5392. /**
  5393. * Creates a new BoneIKController
  5394. * @param mesh defines the mesh to control
  5395. * @param bone defines the bone to control
  5396. * @param options defines options to set up the controller
  5397. */
  5398. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5399. targetMesh?: AbstractMesh;
  5400. poleTargetMesh?: AbstractMesh;
  5401. poleTargetBone?: Bone;
  5402. poleTargetLocalOffset?: Vector3;
  5403. poleAngle?: number;
  5404. bendAxis?: Vector3;
  5405. maxAngle?: number;
  5406. slerpAmount?: number;
  5407. });
  5408. private _setMaxAngle(ang);
  5409. /**
  5410. * Force the controller to update the bones
  5411. */
  5412. update(): void;
  5413. }
  5414. }
  5415. declare module BABYLON {
  5416. /**
  5417. * Class used to make a bone look toward a point in space
  5418. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5419. */
  5420. class BoneLookController {
  5421. private static _tmpVecs;
  5422. private static _tmpQuat;
  5423. private static _tmpMats;
  5424. /**
  5425. * The target Vector3 that the bone will look at
  5426. */
  5427. target: Vector3;
  5428. /**
  5429. * The mesh that the bone is attached to
  5430. */
  5431. mesh: AbstractMesh;
  5432. /**
  5433. * The bone that will be looking to the target
  5434. */
  5435. bone: Bone;
  5436. /**
  5437. * The up axis of the coordinate system that is used when the bone is rotated
  5438. */
  5439. upAxis: Vector3;
  5440. /**
  5441. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5442. */
  5443. upAxisSpace: Space;
  5444. /**
  5445. * Used to make an adjustment to the yaw of the bone
  5446. */
  5447. adjustYaw: number;
  5448. /**
  5449. * Used to make an adjustment to the pitch of the bone
  5450. */
  5451. adjustPitch: number;
  5452. /**
  5453. * Used to make an adjustment to the roll of the bone
  5454. */
  5455. adjustRoll: number;
  5456. /**
  5457. * 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)
  5458. */
  5459. slerpAmount: number;
  5460. private _minYaw;
  5461. private _maxYaw;
  5462. private _minPitch;
  5463. private _maxPitch;
  5464. private _minYawSin;
  5465. private _minYawCos;
  5466. private _maxYawSin;
  5467. private _maxYawCos;
  5468. private _midYawConstraint;
  5469. private _minPitchTan;
  5470. private _maxPitchTan;
  5471. private _boneQuat;
  5472. private _slerping;
  5473. private _transformYawPitch;
  5474. private _transformYawPitchInv;
  5475. private _firstFrameSkipped;
  5476. private _yawRange;
  5477. private _fowardAxis;
  5478. /**
  5479. * Gets or sets the minimum yaw angle that the bone can look to
  5480. */
  5481. minYaw: number;
  5482. /**
  5483. * Gets or sets the maximum yaw angle that the bone can look to
  5484. */
  5485. maxYaw: number;
  5486. /**
  5487. * Gets or sets the minimum pitch angle that the bone can look to
  5488. */
  5489. minPitch: number;
  5490. /**
  5491. * Gets or sets the maximum pitch angle that the bone can look to
  5492. */
  5493. maxPitch: number;
  5494. /**
  5495. * Create a BoneLookController
  5496. * @param mesh the mesh that the bone belongs to
  5497. * @param bone the bone that will be looking to the target
  5498. * @param target the target Vector3 to look at
  5499. * @param settings optional settings:
  5500. * * maxYaw: the maximum angle the bone will yaw to
  5501. * * minYaw: the minimum angle the bone will yaw to
  5502. * * maxPitch: the maximum angle the bone will pitch to
  5503. * * minPitch: the minimum angle the bone will yaw to
  5504. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5505. * * upAxis: the up axis of the coordinate system
  5506. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5507. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5508. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5509. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5510. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5511. * * adjustRoll: used to make an adjustment to the roll of the bone
  5512. **/
  5513. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5514. maxYaw?: number;
  5515. minYaw?: number;
  5516. maxPitch?: number;
  5517. minPitch?: number;
  5518. slerpAmount?: number;
  5519. upAxis?: Vector3;
  5520. upAxisSpace?: Space;
  5521. yawAxis?: Vector3;
  5522. pitchAxis?: Vector3;
  5523. adjustYaw?: number;
  5524. adjustPitch?: number;
  5525. adjustRoll?: number;
  5526. });
  5527. /**
  5528. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5529. */
  5530. update(): void;
  5531. private _getAngleDiff(ang1, ang2);
  5532. private _getAngleBetween(ang1, ang2);
  5533. private _isAngleBetween(ang, ang1, ang2);
  5534. }
  5535. }
  5536. declare module BABYLON {
  5537. /**
  5538. * Class used to handle skinning animations
  5539. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5540. */
  5541. class Skeleton implements IAnimatable {
  5542. /** defines the skeleton name */
  5543. name: string;
  5544. /** defines the skeleton Id */
  5545. id: string;
  5546. /**
  5547. * Gets the list of child bones
  5548. */
  5549. bones: Bone[];
  5550. /**
  5551. * Gets an estimate of the dimension of the skeleton at rest
  5552. */
  5553. dimensionsAtRest: Vector3;
  5554. /**
  5555. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5556. */
  5557. needInitialSkinMatrix: boolean;
  5558. /**
  5559. * Gets the list of animations attached to this skeleton
  5560. */
  5561. animations: Array<Animation>;
  5562. private _scene;
  5563. private _isDirty;
  5564. private _transformMatrices;
  5565. private _meshesWithPoseMatrix;
  5566. private _animatables;
  5567. private _identity;
  5568. private _synchronizedWithMesh;
  5569. private _ranges;
  5570. private _lastAbsoluteTransformsUpdateId;
  5571. /**
  5572. * Specifies if the skeleton should be serialized
  5573. */
  5574. doNotSerialize: boolean;
  5575. private _animationPropertiesOverride;
  5576. /**
  5577. * Gets or sets the animation properties override
  5578. */
  5579. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5580. /**
  5581. * An observable triggered before computing the skeleton's matrices
  5582. */
  5583. onBeforeComputeObservable: Observable<Skeleton>;
  5584. /**
  5585. * Creates a new skeleton
  5586. * @param name defines the skeleton name
  5587. * @param id defines the skeleton Id
  5588. * @param scene defines the hosting scene
  5589. */
  5590. constructor(
  5591. /** defines the skeleton name */
  5592. name: string,
  5593. /** defines the skeleton Id */
  5594. id: string, scene: Scene);
  5595. /**
  5596. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5597. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5598. * @returns a Float32Array containing matrices data
  5599. */
  5600. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5601. /**
  5602. * Gets the current hosting scene
  5603. * @returns a scene object
  5604. */
  5605. getScene(): Scene;
  5606. /**
  5607. * Gets a string representing the current skeleton data
  5608. * @param fullDetails defines a boolean indicating if we want a verbose version
  5609. * @returns a string representing the current skeleton data
  5610. */
  5611. toString(fullDetails?: boolean): string;
  5612. /**
  5613. * Get bone's index searching by name
  5614. * @param name defines bone's name to search for
  5615. * @return the indice of the bone. Returns -1 if not found
  5616. */
  5617. getBoneIndexByName(name: string): number;
  5618. /**
  5619. * Creater a new animation range
  5620. * @param name defines the name of the range
  5621. * @param from defines the start key
  5622. * @param to defines the end key
  5623. */
  5624. createAnimationRange(name: string, from: number, to: number): void;
  5625. /**
  5626. * Delete a specific animation range
  5627. * @param name defines the name of the range
  5628. * @param deleteFrames defines if frames must be removed as well
  5629. */
  5630. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5631. /**
  5632. * Gets a specific animation range
  5633. * @param name defines the name of the range to look for
  5634. * @returns the requested animation range or null if not found
  5635. */
  5636. getAnimationRange(name: string): Nullable<AnimationRange>;
  5637. /**
  5638. * Gets the list of all animation ranges defined on this skeleton
  5639. * @returns an array
  5640. */
  5641. getAnimationRanges(): Nullable<AnimationRange>[];
  5642. /**
  5643. * Copy animation range from a source skeleton.
  5644. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5645. * @param source defines the source skeleton
  5646. * @param name defines the name of the range to copy
  5647. * @param rescaleAsRequired defines if rescaling must be applied if required
  5648. * @returns true if operation was successful
  5649. */
  5650. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5651. /**
  5652. * Forces the skeleton to go to rest pose
  5653. */
  5654. returnToRest(): void;
  5655. private _getHighestAnimationFrame();
  5656. /**
  5657. * Begin a specific animation range
  5658. * @param name defines the name of the range to start
  5659. * @param loop defines if looping must be turned on (false by default)
  5660. * @param speedRatio defines the speed ratio to apply (1 by default)
  5661. * @param onAnimationEnd defines a callback which will be called when animation will end
  5662. * @returns a new animatable
  5663. */
  5664. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5665. /** @hidden */
  5666. _markAsDirty(): void;
  5667. /** @hidden */
  5668. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5669. /** @hidden */
  5670. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5671. /** @hidden */
  5672. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5673. /**
  5674. * Build all resources required to render a skeleton
  5675. */
  5676. prepare(): void;
  5677. /**
  5678. * Gets the list of animatables currently running for this skeleton
  5679. * @returns an array of animatables
  5680. */
  5681. getAnimatables(): IAnimatable[];
  5682. /**
  5683. * Clone the current skeleton
  5684. * @param name defines the name of the new skeleton
  5685. * @param id defines the id of the enw skeleton
  5686. * @returns the new skeleton
  5687. */
  5688. clone(name: string, id: string): Skeleton;
  5689. /**
  5690. * Enable animation blending for this skeleton
  5691. * @param blendingSpeed defines the blending speed to apply
  5692. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5693. */
  5694. enableBlending(blendingSpeed?: number): void;
  5695. /**
  5696. * Releases all resources associated with the current skeleton
  5697. */
  5698. dispose(): void;
  5699. /**
  5700. * Serialize the skeleton in a JSON object
  5701. * @returns a JSON object
  5702. */
  5703. serialize(): any;
  5704. /**
  5705. * Creates a new skeleton from serialized data
  5706. * @param parsedSkeleton defines the serialized data
  5707. * @param scene defines the hosting scene
  5708. * @returns a new skeleton
  5709. */
  5710. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5711. /**
  5712. * Compute all node absolute transforms
  5713. * @param forceUpdate defines if computation must be done even if cache is up to date
  5714. */
  5715. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5716. /**
  5717. * Gets the root pose matrix
  5718. * @returns a matrix
  5719. */
  5720. getPoseMatrix(): Nullable<Matrix>;
  5721. /**
  5722. * Sorts bones per internal index
  5723. */
  5724. sortBones(): void;
  5725. private _sortBones(index, bones, visited);
  5726. }
  5727. }
  5728. declare module BABYLON {
  5729. class BoundingBox implements ICullable {
  5730. vectors: Vector3[];
  5731. center: Vector3;
  5732. centerWorld: Vector3;
  5733. extendSize: Vector3;
  5734. extendSizeWorld: Vector3;
  5735. directions: Vector3[];
  5736. vectorsWorld: Vector3[];
  5737. minimumWorld: Vector3;
  5738. maximumWorld: Vector3;
  5739. minimum: Vector3;
  5740. maximum: Vector3;
  5741. private _worldMatrix;
  5742. /**
  5743. * Creates a new bounding box
  5744. * @param min defines the minimum vector (in local space)
  5745. * @param max defines the maximum vector (in local space)
  5746. */
  5747. constructor(min: Vector3, max: Vector3);
  5748. /**
  5749. * Recreates the entire bounding box from scratch
  5750. * @param min defines the new minimum vector (in local space)
  5751. * @param max defines the new maximum vector (in local space)
  5752. */
  5753. reConstruct(min: Vector3, max: Vector3): void;
  5754. getWorldMatrix(): Matrix;
  5755. setWorldMatrix(matrix: Matrix): BoundingBox;
  5756. _update(world: Matrix): void;
  5757. isInFrustum(frustumPlanes: Plane[]): boolean;
  5758. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5759. intersectsPoint(point: Vector3): boolean;
  5760. intersectsSphere(sphere: BoundingSphere): boolean;
  5761. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5762. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5763. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5764. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5765. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5766. }
  5767. }
  5768. declare module BABYLON {
  5769. interface ICullable {
  5770. isInFrustum(frustumPlanes: Plane[]): boolean;
  5771. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5772. }
  5773. class BoundingInfo implements ICullable {
  5774. minimum: Vector3;
  5775. maximum: Vector3;
  5776. boundingBox: BoundingBox;
  5777. boundingSphere: BoundingSphere;
  5778. private _isLocked;
  5779. constructor(minimum: Vector3, maximum: Vector3);
  5780. isLocked: boolean;
  5781. update(world: Matrix): void;
  5782. /**
  5783. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5784. * @param center New center of the bounding info
  5785. * @param extend New extend of the bounding info
  5786. */
  5787. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5788. isInFrustum(frustumPlanes: Plane[]): boolean;
  5789. /**
  5790. * Gets the world distance between the min and max points of the bounding box
  5791. */
  5792. readonly diagonalLength: number;
  5793. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5794. _checkCollision(collider: Collider): boolean;
  5795. intersectsPoint(point: Vector3): boolean;
  5796. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5797. }
  5798. }
  5799. declare module BABYLON {
  5800. class BoundingSphere {
  5801. center: Vector3;
  5802. radius: number;
  5803. centerWorld: Vector3;
  5804. radiusWorld: number;
  5805. minimum: Vector3;
  5806. maximum: Vector3;
  5807. private _tempRadiusVector;
  5808. /**
  5809. * Creates a new bounding sphere
  5810. * @param min defines the minimum vector (in local space)
  5811. * @param max defines the maximum vector (in local space)
  5812. */
  5813. constructor(min: Vector3, max: Vector3);
  5814. /**
  5815. * Recreates the entire bounding sphere from scratch
  5816. * @param min defines the new minimum vector (in local space)
  5817. * @param max defines the new maximum vector (in local space)
  5818. */
  5819. reConstruct(min: Vector3, max: Vector3): void;
  5820. _update(world: Matrix): void;
  5821. isInFrustum(frustumPlanes: Plane[]): boolean;
  5822. intersectsPoint(point: Vector3): boolean;
  5823. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5824. }
  5825. }
  5826. declare module BABYLON {
  5827. class Ray {
  5828. origin: Vector3;
  5829. direction: Vector3;
  5830. length: number;
  5831. private _edge1;
  5832. private _edge2;
  5833. private _pvec;
  5834. private _tvec;
  5835. private _qvec;
  5836. private _tmpRay;
  5837. constructor(origin: Vector3, direction: Vector3, length?: number);
  5838. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5839. intersectsBox(box: BoundingBox): boolean;
  5840. intersectsSphere(sphere: BoundingSphere): boolean;
  5841. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5842. intersectsPlane(plane: Plane): Nullable<number>;
  5843. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5844. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5845. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5846. private static smallnum;
  5847. private static rayl;
  5848. /**
  5849. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5850. * @param sega the first point of the segment to test the intersection against
  5851. * @param segb the second point of the segment to test the intersection against
  5852. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5853. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5854. */
  5855. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5856. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5857. static Zero(): Ray;
  5858. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5859. /**
  5860. * 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
  5861. * transformed to the given world matrix.
  5862. * @param origin The origin point
  5863. * @param end The end point
  5864. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5865. */
  5866. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5867. static Transform(ray: Ray, matrix: Matrix): Ray;
  5868. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5869. }
  5870. }
  5871. declare module BABYLON {
  5872. class ArcRotateCamera extends TargetCamera {
  5873. alpha: number;
  5874. beta: number;
  5875. radius: number;
  5876. protected _target: Vector3;
  5877. protected _targetHost: Nullable<AbstractMesh>;
  5878. target: Vector3;
  5879. inertialAlphaOffset: number;
  5880. inertialBetaOffset: number;
  5881. inertialRadiusOffset: number;
  5882. lowerAlphaLimit: Nullable<number>;
  5883. upperAlphaLimit: Nullable<number>;
  5884. lowerBetaLimit: number;
  5885. upperBetaLimit: number;
  5886. lowerRadiusLimit: Nullable<number>;
  5887. upperRadiusLimit: Nullable<number>;
  5888. inertialPanningX: number;
  5889. inertialPanningY: number;
  5890. pinchToPanMaxDistance: number;
  5891. panningDistanceLimit: Nullable<number>;
  5892. panningOriginTarget: Vector3;
  5893. panningInertia: number;
  5894. angularSensibilityX: number;
  5895. angularSensibilityY: number;
  5896. pinchPrecision: number;
  5897. pinchDeltaPercentage: number;
  5898. panningSensibility: number;
  5899. keysUp: number[];
  5900. keysDown: number[];
  5901. keysLeft: number[];
  5902. keysRight: number[];
  5903. wheelPrecision: number;
  5904. wheelDeltaPercentage: number;
  5905. zoomOnFactor: number;
  5906. targetScreenOffset: Vector2;
  5907. allowUpsideDown: boolean;
  5908. _viewMatrix: Matrix;
  5909. _useCtrlForPanning: boolean;
  5910. _panningMouseButton: number;
  5911. inputs: ArcRotateCameraInputsManager;
  5912. _reset: () => void;
  5913. panningAxis: Vector3;
  5914. protected _localDirection: Vector3;
  5915. protected _transformedDirection: Vector3;
  5916. private _bouncingBehavior;
  5917. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5918. useBouncingBehavior: boolean;
  5919. private _framingBehavior;
  5920. readonly framingBehavior: Nullable<FramingBehavior>;
  5921. useFramingBehavior: boolean;
  5922. private _autoRotationBehavior;
  5923. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5924. useAutoRotationBehavior: boolean;
  5925. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5926. onCollide: (collidedMesh: AbstractMesh) => void;
  5927. checkCollisions: boolean;
  5928. collisionRadius: Vector3;
  5929. protected _collider: Collider;
  5930. protected _previousPosition: Vector3;
  5931. protected _collisionVelocity: Vector3;
  5932. protected _newPosition: Vector3;
  5933. protected _previousAlpha: number;
  5934. protected _previousBeta: number;
  5935. protected _previousRadius: number;
  5936. protected _collisionTriggered: boolean;
  5937. protected _targetBoundingCenter: Nullable<Vector3>;
  5938. private _computationVector;
  5939. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5940. _initCache(): void;
  5941. _updateCache(ignoreParentClass?: boolean): void;
  5942. protected _getTargetPosition(): Vector3;
  5943. /**
  5944. * Store current camera state (fov, position, etc..)
  5945. */
  5946. private _storedAlpha;
  5947. private _storedBeta;
  5948. private _storedRadius;
  5949. private _storedTarget;
  5950. storeState(): Camera;
  5951. /**
  5952. * Restored camera state. You must call storeState() first
  5953. */
  5954. _restoreStateValues(): boolean;
  5955. _isSynchronizedViewMatrix(): boolean;
  5956. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5957. detachControl(element: HTMLElement): void;
  5958. _checkInputs(): void;
  5959. protected _checkLimits(): void;
  5960. rebuildAnglesAndRadius(): void;
  5961. setPosition(position: Vector3): void;
  5962. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5963. _getViewMatrix(): Matrix;
  5964. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5965. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5966. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5967. min: Vector3;
  5968. max: Vector3;
  5969. distance: number;
  5970. }, doNotUpdateMaxZ?: boolean): void;
  5971. /**
  5972. * @override
  5973. * Override Camera.createRigCamera
  5974. */
  5975. createRigCamera(name: string, cameraIndex: number): Camera;
  5976. /**
  5977. * @override
  5978. * Override Camera._updateRigCameras
  5979. */
  5980. _updateRigCameras(): void;
  5981. dispose(): void;
  5982. getClassName(): string;
  5983. }
  5984. }
  5985. declare module BABYLON {
  5986. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5987. constructor(camera: ArcRotateCamera);
  5988. addMouseWheel(): ArcRotateCameraInputsManager;
  5989. addPointers(): ArcRotateCameraInputsManager;
  5990. addKeyboard(): ArcRotateCameraInputsManager;
  5991. addGamepad(): ArcRotateCameraInputsManager;
  5992. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5993. }
  5994. }
  5995. declare module BABYLON {
  5996. class Camera extends Node {
  5997. inputs: CameraInputsManager<Camera>;
  5998. private static _PERSPECTIVE_CAMERA;
  5999. private static _ORTHOGRAPHIC_CAMERA;
  6000. private static _FOVMODE_VERTICAL_FIXED;
  6001. private static _FOVMODE_HORIZONTAL_FIXED;
  6002. private static _RIG_MODE_NONE;
  6003. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  6004. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  6005. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  6006. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  6007. private static _RIG_MODE_VR;
  6008. private static _RIG_MODE_WEBVR;
  6009. static readonly PERSPECTIVE_CAMERA: number;
  6010. static readonly ORTHOGRAPHIC_CAMERA: number;
  6011. /**
  6012. * This is the default FOV mode for perspective cameras.
  6013. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  6014. *
  6015. */
  6016. static readonly FOVMODE_VERTICAL_FIXED: number;
  6017. /**
  6018. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  6019. *
  6020. */
  6021. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  6022. static readonly RIG_MODE_NONE: number;
  6023. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  6024. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  6025. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  6026. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  6027. static readonly RIG_MODE_VR: number;
  6028. static readonly RIG_MODE_WEBVR: number;
  6029. static ForceAttachControlToAlwaysPreventDefault: boolean;
  6030. static UseAlternateWebVRRendering: boolean;
  6031. position: Vector3;
  6032. /**
  6033. * The vector the camera should consider as up.
  6034. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6035. */
  6036. upVector: Vector3;
  6037. orthoLeft: Nullable<number>;
  6038. orthoRight: Nullable<number>;
  6039. orthoBottom: Nullable<number>;
  6040. orthoTop: Nullable<number>;
  6041. /**
  6042. * FOV is set in Radians. (default is 0.8)
  6043. */
  6044. fov: number;
  6045. minZ: number;
  6046. maxZ: number;
  6047. inertia: number;
  6048. mode: number;
  6049. isIntermediate: boolean;
  6050. viewport: Viewport;
  6051. /**
  6052. * Restricts the camera to viewing objects with the same layerMask.
  6053. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  6054. */
  6055. layerMask: number;
  6056. /**
  6057. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  6058. */
  6059. fovMode: number;
  6060. cameraRigMode: number;
  6061. interaxialDistance: number;
  6062. isStereoscopicSideBySide: boolean;
  6063. _cameraRigParams: any;
  6064. _rigCameras: Camera[];
  6065. _rigPostProcess: Nullable<PostProcess>;
  6066. protected _webvrViewMatrix: Matrix;
  6067. _skipRendering: boolean;
  6068. _alternateCamera: Camera;
  6069. customRenderTargets: RenderTargetTexture[];
  6070. onViewMatrixChangedObservable: Observable<Camera>;
  6071. onProjectionMatrixChangedObservable: Observable<Camera>;
  6072. onAfterCheckInputsObservable: Observable<Camera>;
  6073. onRestoreStateObservable: Observable<Camera>;
  6074. private _computedViewMatrix;
  6075. _projectionMatrix: Matrix;
  6076. private _doNotComputeProjectionMatrix;
  6077. private _worldMatrix;
  6078. _postProcesses: Nullable<PostProcess>[];
  6079. private _transformMatrix;
  6080. _activeMeshes: SmartArray<AbstractMesh>;
  6081. protected _globalPosition: Vector3;
  6082. private _frustumPlanes;
  6083. private _refreshFrustumPlanes;
  6084. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6085. private _storedFov;
  6086. private _stateStored;
  6087. /**
  6088. * Store current camera state (fov, position, etc..)
  6089. */
  6090. storeState(): Camera;
  6091. /**
  6092. * Restores the camera state values if it has been stored. You must call storeState() first
  6093. */
  6094. protected _restoreStateValues(): boolean;
  6095. /**
  6096. * Restored camera state. You must call storeState() first
  6097. */
  6098. restoreState(): boolean;
  6099. getClassName(): string;
  6100. /**
  6101. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6102. */
  6103. toString(fullDetails?: boolean): string;
  6104. readonly globalPosition: Vector3;
  6105. getActiveMeshes(): SmartArray<AbstractMesh>;
  6106. isActiveMesh(mesh: Mesh): boolean;
  6107. /**
  6108. * Is this camera ready to be used/rendered
  6109. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6110. * @return true if the camera is ready
  6111. */
  6112. isReady(completeCheck?: boolean): boolean;
  6113. _initCache(): void;
  6114. _updateCache(ignoreParentClass?: boolean): void;
  6115. _isSynchronized(): boolean;
  6116. _isSynchronizedViewMatrix(): boolean;
  6117. _isSynchronizedProjectionMatrix(): boolean;
  6118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6119. detachControl(element: HTMLElement): void;
  6120. update(): void;
  6121. _checkInputs(): void;
  6122. readonly rigCameras: Camera[];
  6123. readonly rigPostProcess: Nullable<PostProcess>;
  6124. /**
  6125. * Internal, gets the first post proces.
  6126. * @returns the first post process to be run on this camera.
  6127. */
  6128. _getFirstPostProcess(): Nullable<PostProcess>;
  6129. private _cascadePostProcessesToRigCams();
  6130. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6131. detachPostProcess(postProcess: PostProcess): void;
  6132. getWorldMatrix(): Matrix;
  6133. _getViewMatrix(): Matrix;
  6134. getViewMatrix(force?: boolean): Matrix;
  6135. freezeProjectionMatrix(projection?: Matrix): void;
  6136. unfreezeProjectionMatrix(): void;
  6137. getProjectionMatrix(force?: boolean): Matrix;
  6138. getTranformationMatrix(): Matrix;
  6139. private updateFrustumPlanes();
  6140. isInFrustum(target: ICullable): boolean;
  6141. isCompletelyInFrustum(target: ICullable): boolean;
  6142. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6143. /**
  6144. * Releases resources associated with this node.
  6145. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6146. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6147. */
  6148. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6149. readonly leftCamera: Nullable<FreeCamera>;
  6150. readonly rightCamera: Nullable<FreeCamera>;
  6151. getLeftTarget(): Nullable<Vector3>;
  6152. getRightTarget(): Nullable<Vector3>;
  6153. setCameraRigMode(mode: number, rigParams: any): void;
  6154. private _getVRProjectionMatrix();
  6155. protected _updateCameraRotationMatrix(): void;
  6156. protected _updateWebVRCameraRotationMatrix(): void;
  6157. /**
  6158. * This function MUST be overwritten by the different WebVR cameras available.
  6159. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6160. */
  6161. protected _getWebVRProjectionMatrix(): Matrix;
  6162. /**
  6163. * This function MUST be overwritten by the different WebVR cameras available.
  6164. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6165. */
  6166. protected _getWebVRViewMatrix(): Matrix;
  6167. setCameraRigParameter(name: string, value: any): void;
  6168. /**
  6169. * needs to be overridden by children so sub has required properties to be copied
  6170. */
  6171. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6172. /**
  6173. * May need to be overridden by children
  6174. */
  6175. _updateRigCameras(): void;
  6176. _setupInputs(): void;
  6177. serialize(): any;
  6178. clone(name: string): Camera;
  6179. getDirection(localAxis: Vector3): Vector3;
  6180. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6181. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6182. computeWorldMatrix(): Matrix;
  6183. static Parse(parsedCamera: any, scene: Scene): Camera;
  6184. }
  6185. }
  6186. declare module BABYLON {
  6187. var CameraInputTypes: {};
  6188. interface ICameraInput<TCamera extends Camera> {
  6189. camera: Nullable<TCamera>;
  6190. getClassName(): string;
  6191. getSimpleName(): string;
  6192. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6193. detachControl: (element: Nullable<HTMLElement>) => void;
  6194. checkInputs?: () => void;
  6195. }
  6196. interface CameraInputsMap<TCamera extends Camera> {
  6197. [name: string]: ICameraInput<TCamera>;
  6198. [idx: number]: ICameraInput<TCamera>;
  6199. }
  6200. class CameraInputsManager<TCamera extends Camera> {
  6201. attached: CameraInputsMap<TCamera>;
  6202. attachedElement: Nullable<HTMLElement>;
  6203. noPreventDefault: boolean;
  6204. camera: TCamera;
  6205. checkInputs: () => void;
  6206. constructor(camera: TCamera);
  6207. /**
  6208. * Add an input method to a camera.
  6209. * builtin inputs example: camera.inputs.addGamepad();
  6210. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  6211. * @param input camera input method
  6212. */
  6213. add(input: ICameraInput<TCamera>): void;
  6214. /**
  6215. * Remove a specific input method from a camera
  6216. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6217. * @param inputToRemove camera input method
  6218. */
  6219. remove(inputToRemove: ICameraInput<TCamera>): void;
  6220. removeByType(inputType: string): void;
  6221. private _addCheckInputs(fn);
  6222. attachInput(input: ICameraInput<TCamera>): void;
  6223. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6224. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6225. rebuildInputCheck(): void;
  6226. /**
  6227. * Remove all attached input methods from a camera
  6228. */
  6229. clear(): void;
  6230. serialize(serializedCamera: any): void;
  6231. parse(parsedCamera: any): void;
  6232. }
  6233. }
  6234. declare module BABYLON {
  6235. /**
  6236. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6237. * being tilted forward or back and left or right.
  6238. */
  6239. class DeviceOrientationCamera extends FreeCamera {
  6240. private _initialQuaternion;
  6241. private _quaternionCache;
  6242. /**
  6243. * Creates a new device orientation camera
  6244. * @param name The name of the camera
  6245. * @param position The start position camera
  6246. * @param scene The scene the camera belongs to
  6247. */
  6248. constructor(name: string, position: Vector3, scene: Scene);
  6249. /**
  6250. * Gets the current instance class name ("DeviceOrientationCamera").
  6251. * This helps avoiding instanceof at run time.
  6252. * @returns the class name
  6253. */
  6254. getClassName(): string;
  6255. /**
  6256. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6257. */
  6258. _checkInputs(): void;
  6259. /**
  6260. * Reset the camera to its default orientation on the specified axis only.
  6261. * @param axis The axis to reset
  6262. */
  6263. resetToCurrentRotation(axis?: Axis): void;
  6264. }
  6265. }
  6266. declare module BABYLON {
  6267. class FollowCamera extends TargetCamera {
  6268. radius: number;
  6269. rotationOffset: number;
  6270. heightOffset: number;
  6271. cameraAcceleration: number;
  6272. maxCameraSpeed: number;
  6273. lockedTarget: Nullable<AbstractMesh>;
  6274. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6275. private getRadians(degrees);
  6276. private follow(cameraTarget);
  6277. _checkInputs(): void;
  6278. getClassName(): string;
  6279. }
  6280. class ArcFollowCamera extends TargetCamera {
  6281. alpha: number;
  6282. beta: number;
  6283. radius: number;
  6284. target: Nullable<AbstractMesh>;
  6285. private _cartesianCoordinates;
  6286. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6287. private follow();
  6288. _checkInputs(): void;
  6289. getClassName(): string;
  6290. }
  6291. }
  6292. declare module BABYLON {
  6293. class FreeCamera extends TargetCamera {
  6294. ellipsoid: Vector3;
  6295. ellipsoidOffset: Vector3;
  6296. checkCollisions: boolean;
  6297. applyGravity: boolean;
  6298. inputs: FreeCameraInputsManager;
  6299. /**
  6300. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6301. * Higher values reduce sensitivity.
  6302. */
  6303. /**
  6304. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6305. * Higher values reduce sensitivity.
  6306. */
  6307. angularSensibility: number;
  6308. keysUp: number[];
  6309. keysDown: number[];
  6310. keysLeft: number[];
  6311. keysRight: number[];
  6312. onCollide: (collidedMesh: AbstractMesh) => void;
  6313. private _collider;
  6314. private _needMoveForGravity;
  6315. private _oldPosition;
  6316. private _diffPosition;
  6317. private _newPosition;
  6318. _localDirection: Vector3;
  6319. _transformedDirection: Vector3;
  6320. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6322. detachControl(element: HTMLElement): void;
  6323. private _collisionMask;
  6324. collisionMask: number;
  6325. _collideWithWorld(displacement: Vector3): void;
  6326. private _onCollisionPositionChange;
  6327. _checkInputs(): void;
  6328. _decideIfNeedsToMove(): boolean;
  6329. _updatePosition(): void;
  6330. dispose(): void;
  6331. getClassName(): string;
  6332. }
  6333. }
  6334. declare module BABYLON {
  6335. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6336. constructor(camera: FreeCamera);
  6337. addKeyboard(): FreeCameraInputsManager;
  6338. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6339. addGamepad(): FreeCameraInputsManager;
  6340. addDeviceOrientation(): FreeCameraInputsManager;
  6341. addTouch(): FreeCameraInputsManager;
  6342. addVirtualJoystick(): FreeCameraInputsManager;
  6343. }
  6344. }
  6345. declare module BABYLON {
  6346. class GamepadCamera extends UniversalCamera {
  6347. gamepadAngularSensibility: number;
  6348. gamepadMoveSensibility: number;
  6349. constructor(name: string, position: Vector3, scene: Scene);
  6350. getClassName(): string;
  6351. }
  6352. }
  6353. declare module BABYLON {
  6354. /**
  6355. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6356. */
  6357. class AnaglyphFreeCamera extends FreeCamera {
  6358. /**
  6359. * Creates a new AnaglyphFreeCamera
  6360. * @param name defines camera name
  6361. * @param position defines initial position
  6362. * @param interaxialDistance defines distance between each color axis
  6363. * @param scene defines the hosting scene
  6364. */
  6365. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6366. /**
  6367. * Gets camera class name
  6368. * @returns AnaglyphFreeCamera
  6369. */
  6370. getClassName(): string;
  6371. }
  6372. /**
  6373. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6374. */
  6375. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6376. /**
  6377. * Creates a new AnaglyphArcRotateCamera
  6378. * @param name defines camera name
  6379. * @param alpha defines alpha angle (in radians)
  6380. * @param beta defines beta angle (in radians)
  6381. * @param radius defines radius
  6382. * @param target defines camera target
  6383. * @param interaxialDistance defines distance between each color axis
  6384. * @param scene defines the hosting scene
  6385. */
  6386. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6387. /**
  6388. * Gets camera class name
  6389. * @returns AnaglyphArcRotateCamera
  6390. */
  6391. getClassName(): string;
  6392. }
  6393. /**
  6394. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6395. */
  6396. class AnaglyphGamepadCamera extends GamepadCamera {
  6397. /**
  6398. * Creates a new AnaglyphGamepadCamera
  6399. * @param name defines camera name
  6400. * @param position defines initial position
  6401. * @param interaxialDistance defines distance between each color axis
  6402. * @param scene defines the hosting scene
  6403. */
  6404. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6405. /**
  6406. * Gets camera class name
  6407. * @returns AnaglyphGamepadCamera
  6408. */
  6409. getClassName(): string;
  6410. }
  6411. /**
  6412. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6413. */
  6414. class AnaglyphUniversalCamera extends UniversalCamera {
  6415. /**
  6416. * Creates a new AnaglyphUniversalCamera
  6417. * @param name defines camera name
  6418. * @param position defines initial position
  6419. * @param interaxialDistance defines distance between each color axis
  6420. * @param scene defines the hosting scene
  6421. */
  6422. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6423. /**
  6424. * Gets camera class name
  6425. * @returns AnaglyphUniversalCamera
  6426. */
  6427. getClassName(): string;
  6428. }
  6429. /**
  6430. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6431. */
  6432. class StereoscopicFreeCamera extends FreeCamera {
  6433. /**
  6434. * Creates a new StereoscopicFreeCamera
  6435. * @param name defines camera name
  6436. * @param position defines initial position
  6437. * @param interaxialDistance defines distance between each color axis
  6438. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6439. * @param scene defines the hosting scene
  6440. */
  6441. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6442. /**
  6443. * Gets camera class name
  6444. * @returns StereoscopicFreeCamera
  6445. */
  6446. getClassName(): string;
  6447. }
  6448. /**
  6449. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6450. */
  6451. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6452. /**
  6453. * Creates a new StereoscopicArcRotateCamera
  6454. * @param name defines camera name
  6455. * @param alpha defines alpha angle (in radians)
  6456. * @param beta defines beta angle (in radians)
  6457. * @param radius defines radius
  6458. * @param target defines camera target
  6459. * @param interaxialDistance defines distance between each color axis
  6460. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6461. * @param scene defines the hosting scene
  6462. */
  6463. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6464. /**
  6465. * Gets camera class name
  6466. * @returns StereoscopicArcRotateCamera
  6467. */
  6468. getClassName(): string;
  6469. }
  6470. /**
  6471. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6472. */
  6473. class StereoscopicGamepadCamera extends GamepadCamera {
  6474. /**
  6475. * Creates a new StereoscopicGamepadCamera
  6476. * @param name defines camera name
  6477. * @param position defines initial position
  6478. * @param interaxialDistance defines distance between each color axis
  6479. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6480. * @param scene defines the hosting scene
  6481. */
  6482. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6483. /**
  6484. * Gets camera class name
  6485. * @returns StereoscopicGamepadCamera
  6486. */
  6487. getClassName(): string;
  6488. }
  6489. /**
  6490. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6491. */
  6492. class StereoscopicUniversalCamera extends UniversalCamera {
  6493. /**
  6494. * Creates a new StereoscopicUniversalCamera
  6495. * @param name defines camera name
  6496. * @param position defines initial position
  6497. * @param interaxialDistance defines distance between each color axis
  6498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6499. * @param scene defines the hosting scene
  6500. */
  6501. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6502. /**
  6503. * Gets camera class name
  6504. * @returns StereoscopicUniversalCamera
  6505. */
  6506. getClassName(): string;
  6507. }
  6508. }
  6509. declare module BABYLON {
  6510. class TargetCamera extends Camera {
  6511. cameraDirection: Vector3;
  6512. cameraRotation: Vector2;
  6513. rotation: Vector3;
  6514. rotationQuaternion: Quaternion;
  6515. speed: number;
  6516. noRotationConstraint: boolean;
  6517. lockedTarget: any;
  6518. _currentTarget: Vector3;
  6519. _viewMatrix: Matrix;
  6520. _camMatrix: Matrix;
  6521. _cameraTransformMatrix: Matrix;
  6522. _cameraRotationMatrix: Matrix;
  6523. private _rigCamTransformMatrix;
  6524. _referencePoint: Vector3;
  6525. private _currentUpVector;
  6526. _transformedReferencePoint: Vector3;
  6527. protected _globalCurrentTarget: Vector3;
  6528. protected _globalCurrentUpVector: Vector3;
  6529. _reset: () => void;
  6530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6531. getFrontPosition(distance: number): Vector3;
  6532. _getLockedTargetPosition(): Nullable<Vector3>;
  6533. /**
  6534. * Store current camera state (fov, position, etc..)
  6535. */
  6536. private _storedPosition;
  6537. private _storedRotation;
  6538. private _storedRotationQuaternion;
  6539. storeState(): Camera;
  6540. /**
  6541. * Restored camera state. You must call storeState() first
  6542. */
  6543. _restoreStateValues(): boolean;
  6544. _initCache(): void;
  6545. _updateCache(ignoreParentClass?: boolean): void;
  6546. _isSynchronizedViewMatrix(): boolean;
  6547. _computeLocalCameraSpeed(): number;
  6548. setTarget(target: Vector3): void;
  6549. /**
  6550. * Return the current target position of the camera. This value is expressed in local space.
  6551. */
  6552. getTarget(): Vector3;
  6553. _decideIfNeedsToMove(): boolean;
  6554. _updatePosition(): void;
  6555. _checkInputs(): void;
  6556. protected _updateCameraRotationMatrix(): void;
  6557. _getViewMatrix(): Matrix;
  6558. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6559. /**
  6560. * @override
  6561. * Override Camera.createRigCamera
  6562. */
  6563. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6564. /**
  6565. * @override
  6566. * Override Camera._updateRigCameras
  6567. */
  6568. _updateRigCameras(): void;
  6569. private _getRigCamPosition(halfSpace, result);
  6570. getClassName(): string;
  6571. }
  6572. }
  6573. declare module BABYLON {
  6574. class TouchCamera extends FreeCamera {
  6575. touchAngularSensibility: number;
  6576. touchMoveSensibility: number;
  6577. constructor(name: string, position: Vector3, scene: Scene);
  6578. getClassName(): string;
  6579. _setupInputs(): void;
  6580. }
  6581. }
  6582. declare module BABYLON {
  6583. class UniversalCamera extends TouchCamera {
  6584. gamepadAngularSensibility: number;
  6585. gamepadMoveSensibility: number;
  6586. constructor(name: string, position: Vector3, scene: Scene);
  6587. getClassName(): string;
  6588. }
  6589. }
  6590. declare module BABYLON {
  6591. class VirtualJoysticksCamera extends FreeCamera {
  6592. constructor(name: string, position: Vector3, scene: Scene);
  6593. getClassName(): string;
  6594. }
  6595. }
  6596. interface VRDisplay extends EventTarget {
  6597. /**
  6598. * Dictionary of capabilities describing the VRDisplay.
  6599. */
  6600. readonly capabilities: VRDisplayCapabilities;
  6601. /**
  6602. * z-depth defining the far plane of the eye view frustum
  6603. * enables mapping of values in the render target depth
  6604. * attachment to scene coordinates. Initially set to 10000.0.
  6605. */
  6606. depthFar: number;
  6607. /**
  6608. * z-depth defining the near plane of the eye view frustum
  6609. * enables mapping of values in the render target depth
  6610. * attachment to scene coordinates. Initially set to 0.01.
  6611. */
  6612. depthNear: number;
  6613. /**
  6614. * An identifier for this distinct VRDisplay. Used as an
  6615. * association point in the Gamepad API.
  6616. */
  6617. readonly displayId: number;
  6618. /**
  6619. * A display name, a user-readable name identifying it.
  6620. */
  6621. readonly displayName: string;
  6622. readonly isConnected: boolean;
  6623. readonly isPresenting: boolean;
  6624. /**
  6625. * If this VRDisplay supports room-scale experiences, the optional
  6626. * stage attribute contains details on the room-scale parameters.
  6627. */
  6628. readonly stageParameters: VRStageParameters | null;
  6629. /**
  6630. * Passing the value returned by `requestAnimationFrame` to
  6631. * `cancelAnimationFrame` will unregister the callback.
  6632. */
  6633. cancelAnimationFrame(handle: number): void;
  6634. /**
  6635. * Stops presenting to the VRDisplay.
  6636. */
  6637. exitPresent(): Promise<void>;
  6638. getEyeParameters(whichEye: string): VREyeParameters;
  6639. /**
  6640. * Populates the passed VRFrameData with the information required to render
  6641. * the current frame.
  6642. */
  6643. getFrameData(frameData: VRFrameData): boolean;
  6644. /**
  6645. * Get the layers currently being presented.
  6646. */
  6647. getLayers(): VRLayer[];
  6648. /**
  6649. * Return a VRPose containing the future predicted pose of the VRDisplay
  6650. * when the current frame will be presented. The value returned will not
  6651. * change until JavaScript has returned control to the browser.
  6652. *
  6653. * The VRPose will contain the position, orientation, velocity,
  6654. * and acceleration of each of these properties.
  6655. */
  6656. getPose(): VRPose;
  6657. /**
  6658. * Return the current instantaneous pose of the VRDisplay, with no
  6659. * prediction applied.
  6660. */
  6661. getImmediatePose(): VRPose;
  6662. /**
  6663. * The callback passed to `requestAnimationFrame` will be called
  6664. * any time a new frame should be rendered. When the VRDisplay is
  6665. * presenting the callback will be called at the native refresh
  6666. * rate of the HMD. When not presenting this function acts
  6667. * identically to how window.requestAnimationFrame acts. Content should
  6668. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6669. * asynchronously from other displays and at differing refresh rates.
  6670. */
  6671. requestAnimationFrame(callback: FrameRequestCallback): number;
  6672. /**
  6673. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6674. * Repeat calls while already presenting will update the VRLayers being displayed.
  6675. */
  6676. requestPresent(layers: VRLayer[]): Promise<void>;
  6677. /**
  6678. * Reset the pose for this display, treating its current position and
  6679. * orientation as the "origin/zero" values. VRPose.position,
  6680. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6681. * updated when calling resetPose(). This should be called in only
  6682. * sitting-space experiences.
  6683. */
  6684. resetPose(): void;
  6685. /**
  6686. * The VRLayer provided to the VRDisplay will be captured and presented
  6687. * in the HMD. Calling this function has the same effect on the source
  6688. * canvas as any other operation that uses its source image, and canvases
  6689. * created without preserveDrawingBuffer set to true will be cleared.
  6690. */
  6691. submitFrame(pose?: VRPose): void;
  6692. }
  6693. declare var VRDisplay: {
  6694. prototype: VRDisplay;
  6695. new (): VRDisplay;
  6696. };
  6697. interface VRLayer {
  6698. leftBounds?: number[] | null;
  6699. rightBounds?: number[] | null;
  6700. source?: HTMLCanvasElement | null;
  6701. }
  6702. interface VRDisplayCapabilities {
  6703. readonly canPresent: boolean;
  6704. readonly hasExternalDisplay: boolean;
  6705. readonly hasOrientation: boolean;
  6706. readonly hasPosition: boolean;
  6707. readonly maxLayers: number;
  6708. }
  6709. interface VREyeParameters {
  6710. /** @deprecated */
  6711. readonly fieldOfView: VRFieldOfView;
  6712. readonly offset: Float32Array;
  6713. readonly renderHeight: number;
  6714. readonly renderWidth: number;
  6715. }
  6716. interface VRFieldOfView {
  6717. readonly downDegrees: number;
  6718. readonly leftDegrees: number;
  6719. readonly rightDegrees: number;
  6720. readonly upDegrees: number;
  6721. }
  6722. interface VRFrameData {
  6723. readonly leftProjectionMatrix: Float32Array;
  6724. readonly leftViewMatrix: Float32Array;
  6725. readonly pose: VRPose;
  6726. readonly rightProjectionMatrix: Float32Array;
  6727. readonly rightViewMatrix: Float32Array;
  6728. readonly timestamp: number;
  6729. }
  6730. interface VRPose {
  6731. readonly angularAcceleration: Float32Array | null;
  6732. readonly angularVelocity: Float32Array | null;
  6733. readonly linearAcceleration: Float32Array | null;
  6734. readonly linearVelocity: Float32Array | null;
  6735. readonly orientation: Float32Array | null;
  6736. readonly position: Float32Array | null;
  6737. readonly timestamp: number;
  6738. }
  6739. interface VRStageParameters {
  6740. sittingToStandingTransform?: Float32Array;
  6741. sizeX?: number;
  6742. sizeY?: number;
  6743. }
  6744. interface Navigator {
  6745. getVRDisplays(): Promise<VRDisplay[]>;
  6746. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6747. }
  6748. interface Window {
  6749. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6750. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6751. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6752. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6753. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6754. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6755. }
  6756. interface Gamepad {
  6757. readonly displayId: number;
  6758. }
  6759. declare module BABYLON {
  6760. /**
  6761. * Interface for attribute information associated with buffer instanciation
  6762. */
  6763. class InstancingAttributeInfo {
  6764. /**
  6765. * Index/offset of the attribute in the vertex shader
  6766. */
  6767. index: number;
  6768. /**
  6769. * size of the attribute, 1, 2, 3 or 4
  6770. */
  6771. attributeSize: number;
  6772. /**
  6773. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6774. * default is FLOAT
  6775. */
  6776. attribyteType: number;
  6777. /**
  6778. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6779. */
  6780. normalized: boolean;
  6781. /**
  6782. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6783. */
  6784. offset: number;
  6785. /**
  6786. * Name of the GLSL attribute, for debugging purpose only
  6787. */
  6788. attributeName: string;
  6789. }
  6790. /**
  6791. * Define options used to create a render target texture
  6792. */
  6793. class RenderTargetCreationOptions {
  6794. /**
  6795. * Specifies is mipmaps must be generated
  6796. */
  6797. generateMipMaps?: boolean;
  6798. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6799. generateDepthBuffer?: boolean;
  6800. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6801. generateStencilBuffer?: boolean;
  6802. /** Defines texture type (int by default) */
  6803. type?: number;
  6804. /** Defines sampling mode (trilinear by default) */
  6805. samplingMode?: number;
  6806. /** Defines format (RGBA by default) */
  6807. format?: number;
  6808. }
  6809. /**
  6810. * Define options used to create a depth texture
  6811. */
  6812. class DepthTextureCreationOptions {
  6813. /** Specifies whether or not a stencil should be allocated in the texture */
  6814. generateStencil?: boolean;
  6815. /** Specifies whether or not bilinear filtering is enable on the texture */
  6816. bilinearFiltering?: boolean;
  6817. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6818. comparisonFunction?: number;
  6819. /** Specifies if the created texture is a cube texture */
  6820. isCube?: boolean;
  6821. }
  6822. /**
  6823. * Class used to describe the capabilities of the engine relatively to the current browser
  6824. */
  6825. class EngineCapabilities {
  6826. /** Maximum textures units per fragment shader */
  6827. maxTexturesImageUnits: number;
  6828. /** Maximum texture units per vertex shader */
  6829. maxVertexTextureImageUnits: number;
  6830. /** Maximum textures units in the entire pipeline */
  6831. maxCombinedTexturesImageUnits: number;
  6832. /** Maximum texture size */
  6833. maxTextureSize: number;
  6834. /** Maximum cube texture size */
  6835. maxCubemapTextureSize: number;
  6836. /** Maximum render texture size */
  6837. maxRenderTextureSize: number;
  6838. /** Maximum number of vertex attributes */
  6839. maxVertexAttribs: number;
  6840. /** Maximum number of varyings */
  6841. maxVaryingVectors: number;
  6842. /** Maximum number of uniforms per vertex shader */
  6843. maxVertexUniformVectors: number;
  6844. /** Maximum number of uniforms per fragment shader */
  6845. maxFragmentUniformVectors: number;
  6846. /** Defines if standard derivates (dx/dy) are supported */
  6847. standardDerivatives: boolean;
  6848. /** Defines if s3tc texture compression is supported */
  6849. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6850. /** Defines if pvrtc texture compression is supported */
  6851. pvrtc: any;
  6852. /** Defines if etc1 texture compression is supported */
  6853. etc1: any;
  6854. /** Defines if etc2 texture compression is supported */
  6855. etc2: any;
  6856. /** Defines if astc texture compression is supported */
  6857. astc: any;
  6858. /** Defines if float textures are supported */
  6859. textureFloat: boolean;
  6860. /** Defines if vertex array objects are supported */
  6861. vertexArrayObject: boolean;
  6862. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6863. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6864. /** Gets the maximum level of anisotropy supported */
  6865. maxAnisotropy: number;
  6866. /** Defines if instancing is supported */
  6867. instancedArrays: boolean;
  6868. /** Defines if 32 bits indices are supported */
  6869. uintIndices: boolean;
  6870. /** Defines if high precision shaders are supported */
  6871. highPrecisionShaderSupported: boolean;
  6872. /** Defines if depth reading in the fragment shader is supported */
  6873. fragmentDepthSupported: boolean;
  6874. /** Defines if float texture linear filtering is supported*/
  6875. textureFloatLinearFiltering: boolean;
  6876. /** Defines if rendering to float textures is supported */
  6877. textureFloatRender: boolean;
  6878. /** Defines if half float textures are supported*/
  6879. textureHalfFloat: boolean;
  6880. /** Defines if half float texture linear filtering is supported*/
  6881. textureHalfFloatLinearFiltering: boolean;
  6882. /** Defines if rendering to half float textures is supported */
  6883. textureHalfFloatRender: boolean;
  6884. /** Defines if textureLOD shader command is supported */
  6885. textureLOD: boolean;
  6886. /** Defines if draw buffers extension is supported */
  6887. drawBuffersExtension: boolean;
  6888. /** Defines if depth textures are supported */
  6889. depthTextureExtension: boolean;
  6890. /** Defines if float color buffer are supported */
  6891. colorBufferFloat: boolean;
  6892. /** Gets disjoint timer query extension (null if not supported) */
  6893. timerQuery: EXT_disjoint_timer_query;
  6894. /** Defines if timestamp can be used with timer query */
  6895. canUseTimestampForTimerQuery: boolean;
  6896. }
  6897. /** Interface defining initialization parameters for Engine class */
  6898. interface EngineOptions extends WebGLContextAttributes {
  6899. /**
  6900. * Defines if the engine should no exceed a specified device ratio
  6901. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6902. */
  6903. limitDeviceRatio?: number;
  6904. /**
  6905. * Defines if webvr should be enabled automatically
  6906. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6907. */
  6908. autoEnableWebVR?: boolean;
  6909. /**
  6910. * Defines if webgl2 should be turned off even if supported
  6911. * @see http://doc.babylonjs.com/features/webgl2
  6912. */
  6913. disableWebGL2Support?: boolean;
  6914. /**
  6915. * Defines if webaudio should be initialized as well
  6916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6917. */
  6918. audioEngine?: boolean;
  6919. /**
  6920. * Defines if animations should run using a deterministic lock step
  6921. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6922. */
  6923. deterministicLockstep?: boolean;
  6924. /** Defines the maximum steps to use with deterministic lock step mode */
  6925. lockstepMaxSteps?: number;
  6926. /**
  6927. * Defines that engine should ignore context lost events
  6928. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6929. */
  6930. doNotHandleContextLost?: boolean;
  6931. }
  6932. /**
  6933. * Defines the interface used by display changed events
  6934. */
  6935. interface IDisplayChangedEventArgs {
  6936. /** Gets the vrDisplay object (if any) */
  6937. vrDisplay: Nullable<any>;
  6938. /** Gets a boolean indicating if webVR is supported */
  6939. vrSupported: boolean;
  6940. }
  6941. /**
  6942. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6943. */
  6944. class Engine {
  6945. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6946. static ExceptionList: ({
  6947. key: string;
  6948. capture: string;
  6949. captureConstraint: number;
  6950. targets: string[];
  6951. } | {
  6952. key: string;
  6953. capture: null;
  6954. captureConstraint: null;
  6955. targets: string[];
  6956. })[];
  6957. /** Gets the list of created engines */
  6958. static Instances: Engine[];
  6959. /**
  6960. * Gets the latest created engine
  6961. */
  6962. static readonly LastCreatedEngine: Nullable<Engine>;
  6963. /**
  6964. * Gets the latest created scene
  6965. */
  6966. static readonly LastCreatedScene: Nullable<Scene>;
  6967. /**
  6968. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6969. * @param flag defines which part of the materials must be marked as dirty
  6970. * @param predicate defines a predicate used to filter which materials should be affected
  6971. */
  6972. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6973. private static _ALPHA_DISABLE;
  6974. private static _ALPHA_ADD;
  6975. private static _ALPHA_COMBINE;
  6976. private static _ALPHA_SUBTRACT;
  6977. private static _ALPHA_MULTIPLY;
  6978. private static _ALPHA_MAXIMIZED;
  6979. private static _ALPHA_ONEONE;
  6980. private static _ALPHA_PREMULTIPLIED;
  6981. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6982. private static _ALPHA_INTERPOLATE;
  6983. private static _ALPHA_SCREENMODE;
  6984. private static _DELAYLOADSTATE_NONE;
  6985. private static _DELAYLOADSTATE_LOADED;
  6986. private static _DELAYLOADSTATE_LOADING;
  6987. private static _DELAYLOADSTATE_NOTLOADED;
  6988. private static _TEXTUREFORMAT_ALPHA;
  6989. private static _TEXTUREFORMAT_LUMINANCE;
  6990. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6991. private static _TEXTUREFORMAT_RGB;
  6992. private static _TEXTUREFORMAT_RGBA;
  6993. private static _TEXTUREFORMAT_R;
  6994. private static _TEXTUREFORMAT_RG;
  6995. private static _TEXTURETYPE_UNSIGNED_INT;
  6996. private static _TEXTURETYPE_FLOAT;
  6997. private static _TEXTURETYPE_HALF_FLOAT;
  6998. private static _NEVER;
  6999. private static _ALWAYS;
  7000. private static _LESS;
  7001. private static _EQUAL;
  7002. private static _LEQUAL;
  7003. private static _GREATER;
  7004. private static _GEQUAL;
  7005. private static _NOTEQUAL;
  7006. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7007. static readonly NEVER: number;
  7008. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  7009. static readonly ALWAYS: number;
  7010. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7011. static readonly LESS: number;
  7012. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7013. static readonly EQUAL: number;
  7014. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  7015. static readonly LEQUAL: number;
  7016. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7017. static readonly GREATER: number;
  7018. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  7019. static readonly GEQUAL: number;
  7020. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  7021. static readonly NOTEQUAL: number;
  7022. private static _KEEP;
  7023. private static _REPLACE;
  7024. private static _INCR;
  7025. private static _DECR;
  7026. private static _INVERT;
  7027. private static _INCR_WRAP;
  7028. private static _DECR_WRAP;
  7029. /** Passed to stencilOperation to specify that stencil value must be kept */
  7030. static readonly KEEP: number;
  7031. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7032. static readonly REPLACE: number;
  7033. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7034. static readonly INCR: number;
  7035. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7036. static readonly DECR: number;
  7037. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7038. static readonly INVERT: number;
  7039. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7040. static readonly INCR_WRAP: number;
  7041. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7042. static readonly DECR_WRAP: number;
  7043. /** Defines that alpha blending is disabled */
  7044. static readonly ALPHA_DISABLE: number;
  7045. /** Defines that alpha blending to SRC + DEST */
  7046. static readonly ALPHA_ONEONE: number;
  7047. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7048. static readonly ALPHA_ADD: number;
  7049. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7050. static readonly ALPHA_COMBINE: number;
  7051. /** Defines that alpha blending to DEST - SRC * DEST */
  7052. static readonly ALPHA_SUBTRACT: number;
  7053. /** Defines that alpha blending to SRC * DEST */
  7054. static readonly ALPHA_MULTIPLY: number;
  7055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7056. static readonly ALPHA_MAXIMIZED: number;
  7057. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7058. static readonly ALPHA_PREMULTIPLIED: number;
  7059. /**
  7060. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7061. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7062. */
  7063. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7064. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7065. static readonly ALPHA_INTERPOLATE: number;
  7066. /**
  7067. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7068. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7069. */
  7070. static readonly ALPHA_SCREENMODE: number;
  7071. /** Defines that the ressource is not delayed*/
  7072. static readonly DELAYLOADSTATE_NONE: number;
  7073. /** Defines that the ressource was successfully delay loaded */
  7074. static readonly DELAYLOADSTATE_LOADED: number;
  7075. /** Defines that the ressource is currently delay loading */
  7076. static readonly DELAYLOADSTATE_LOADING: number;
  7077. /** Defines that the ressource is delayed and has not started loading */
  7078. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7079. /** ALPHA */
  7080. static readonly TEXTUREFORMAT_ALPHA: number;
  7081. /** LUMINANCE */
  7082. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7083. /**
  7084. * R
  7085. */
  7086. static readonly TEXTUREFORMAT_R: number;
  7087. /**
  7088. * RG
  7089. */
  7090. static readonly TEXTUREFORMAT_RG: number;
  7091. /** LUMINANCE_ALPHA */
  7092. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7093. /** RGB */
  7094. static readonly TEXTUREFORMAT_RGB: number;
  7095. /** RGBA */
  7096. static readonly TEXTUREFORMAT_RGBA: number;
  7097. /** UNSIGNED_INT */
  7098. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7099. /** FLOAT */
  7100. static readonly TEXTURETYPE_FLOAT: number;
  7101. /** HALF_FLOAT */
  7102. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7103. private static _SCALEMODE_FLOOR;
  7104. private static _SCALEMODE_NEAREST;
  7105. private static _SCALEMODE_CEILING;
  7106. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7107. static readonly SCALEMODE_FLOOR: number;
  7108. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7109. static readonly SCALEMODE_NEAREST: number;
  7110. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7111. static readonly SCALEMODE_CEILING: number;
  7112. /**
  7113. * Returns the current version of the framework
  7114. */
  7115. static readonly Version: string;
  7116. /**
  7117. * Gets or sets the epsilon value used by collision engine
  7118. */
  7119. static CollisionsEpsilon: number;
  7120. /**
  7121. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7122. */
  7123. static CodeRepository: string;
  7124. /**
  7125. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7126. */
  7127. static ShadersRepository: string;
  7128. /**
  7129. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7130. */
  7131. forcePOTTextures: boolean;
  7132. /**
  7133. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7134. */
  7135. isFullscreen: boolean;
  7136. /**
  7137. * Gets a boolean indicating if the pointer is currently locked
  7138. */
  7139. isPointerLock: boolean;
  7140. /**
  7141. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7142. */
  7143. cullBackFaces: boolean;
  7144. /**
  7145. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7146. */
  7147. renderEvenInBackground: boolean;
  7148. /**
  7149. * Gets or sets a boolean indicating that cache can be kept between frames
  7150. */
  7151. preventCacheWipeBetweenFrames: boolean;
  7152. /**
  7153. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7154. **/
  7155. enableOfflineSupport: boolean;
  7156. /**
  7157. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  7158. **/
  7159. disableManifestCheck: boolean;
  7160. /**
  7161. * Gets the list of created scenes
  7162. */
  7163. scenes: Scene[];
  7164. /**
  7165. * Gets the list of created postprocesses
  7166. */
  7167. postProcesses: PostProcess[];
  7168. /**
  7169. * Observable event triggered each time the rendering canvas is resized
  7170. */
  7171. onResizeObservable: Observable<Engine>;
  7172. /**
  7173. * Observable event triggered each time the canvas loses focus
  7174. */
  7175. onCanvasBlurObservable: Observable<Engine>;
  7176. /**
  7177. * Observable event triggered each time the canvas gains focus
  7178. */
  7179. onCanvasFocusObservable: Observable<Engine>;
  7180. /**
  7181. * Observable event triggered each time the canvas receives pointerout event
  7182. */
  7183. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7184. /**
  7185. * Observable event triggered before each texture is initialized
  7186. */
  7187. onBeforeTextureInitObservable: Observable<Texture>;
  7188. private _vrDisplay;
  7189. private _vrSupported;
  7190. private _oldSize;
  7191. private _oldHardwareScaleFactor;
  7192. private _vrExclusivePointerMode;
  7193. private _webVRInitPromise;
  7194. /**
  7195. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7196. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7197. */
  7198. readonly isInVRExclusivePointerMode: boolean;
  7199. /**
  7200. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7201. */
  7202. disableUniformBuffers: boolean;
  7203. /** @hidden */
  7204. _uniformBuffers: UniformBuffer[];
  7205. /**
  7206. * Gets a boolean indicating that the engine supports uniform buffers
  7207. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7208. */
  7209. readonly supportsUniformBuffers: boolean;
  7210. /**
  7211. * Observable raised when the engine begins a new frame
  7212. */
  7213. onBeginFrameObservable: Observable<Engine>;
  7214. /**
  7215. * Observable raised when the engine ends the current frame
  7216. */
  7217. onEndFrameObservable: Observable<Engine>;
  7218. /**
  7219. * Observable raised when the engine is about to compile a shader
  7220. */
  7221. onBeforeShaderCompilationObservable: Observable<Engine>;
  7222. /**
  7223. * Observable raised when the engine has jsut compiled a shader
  7224. */
  7225. onAfterShaderCompilationObservable: Observable<Engine>;
  7226. private _gl;
  7227. private _renderingCanvas;
  7228. private _windowIsBackground;
  7229. private _webGLVersion;
  7230. /**
  7231. * Gets a boolean indicating that only power of 2 textures are supported
  7232. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7233. */
  7234. readonly needPOTTextures: boolean;
  7235. /** @hidden */
  7236. _badOS: boolean;
  7237. /** @hidden */
  7238. _badDesktopOS: boolean;
  7239. /**
  7240. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7241. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7242. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7243. */
  7244. disableTextureBindingOptimization: boolean;
  7245. /**
  7246. * Gets the audio engine
  7247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7248. * @ignorenaming
  7249. */
  7250. static audioEngine: AudioEngine;
  7251. private _onFocus;
  7252. private _onBlur;
  7253. private _onCanvasPointerOut;
  7254. private _onCanvasBlur;
  7255. private _onCanvasFocus;
  7256. private _onFullscreenChange;
  7257. private _onPointerLockChange;
  7258. private _onVRDisplayPointerRestricted;
  7259. private _onVRDisplayPointerUnrestricted;
  7260. private _onVrDisplayConnect;
  7261. private _onVrDisplayDisconnect;
  7262. private _onVrDisplayPresentChange;
  7263. /**
  7264. * Observable signaled when VR display mode changes
  7265. */
  7266. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7267. /**
  7268. * Observable signaled when VR request present is complete
  7269. */
  7270. onVRRequestPresentComplete: Observable<boolean>;
  7271. /**
  7272. * Observable signaled when VR request present starts
  7273. */
  7274. onVRRequestPresentStart: Observable<Engine>;
  7275. private _hardwareScalingLevel;
  7276. /** @hidden */
  7277. protected _caps: EngineCapabilities;
  7278. private _pointerLockRequested;
  7279. private _isStencilEnable;
  7280. private _colorWrite;
  7281. private _loadingScreen;
  7282. /** @hidden */
  7283. _drawCalls: PerfCounter;
  7284. /** @hidden */
  7285. _textureCollisions: PerfCounter;
  7286. private _glVersion;
  7287. private _glRenderer;
  7288. private _glVendor;
  7289. private _videoTextureSupported;
  7290. private _renderingQueueLaunched;
  7291. private _activeRenderLoops;
  7292. private _deterministicLockstep;
  7293. private _lockstepMaxSteps;
  7294. /**
  7295. * Observable signaled when a context lost event is raised
  7296. */
  7297. onContextLostObservable: Observable<Engine>;
  7298. /**
  7299. * Observable signaled when a context restored event is raised
  7300. */
  7301. onContextRestoredObservable: Observable<Engine>;
  7302. private _onContextLost;
  7303. private _onContextRestored;
  7304. private _contextWasLost;
  7305. private _doNotHandleContextLost;
  7306. /**
  7307. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7309. */
  7310. doNotHandleContextLost: boolean;
  7311. private _performanceMonitor;
  7312. private _fps;
  7313. private _deltaTime;
  7314. /**
  7315. * Turn this value on if you want to pause FPS computation when in background
  7316. */
  7317. disablePerformanceMonitorInBackground: boolean;
  7318. /**
  7319. * Gets the performance monitor attached to this engine
  7320. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7321. */
  7322. readonly performanceMonitor: PerformanceMonitor;
  7323. /** @hidden */
  7324. protected _depthCullingState: _DepthCullingState;
  7325. /** @hidden */
  7326. protected _stencilState: _StencilState;
  7327. /** @hidden */
  7328. protected _alphaState: _AlphaState;
  7329. /** @hidden */
  7330. protected _alphaMode: number;
  7331. protected _internalTexturesCache: InternalTexture[];
  7332. /** @hidden */
  7333. protected _activeChannel: number;
  7334. private _currentTextureChannel;
  7335. /** @hidden */
  7336. protected _boundTexturesCache: {
  7337. [key: string]: Nullable<InternalTexture>;
  7338. };
  7339. /** @hidden */
  7340. protected _currentEffect: Nullable<Effect>;
  7341. /** @hidden */
  7342. protected _currentProgram: Nullable<WebGLProgram>;
  7343. private _compiledEffects;
  7344. private _vertexAttribArraysEnabled;
  7345. /** @hidden */
  7346. protected _cachedViewport: Nullable<Viewport>;
  7347. private _cachedVertexArrayObject;
  7348. /** @hidden */
  7349. protected _cachedVertexBuffers: any;
  7350. /** @hidden */
  7351. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7352. /** @hidden */
  7353. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7354. /** @hidden */
  7355. protected _currentRenderTarget: Nullable<InternalTexture>;
  7356. private _uintIndicesCurrentlySet;
  7357. private _currentBoundBuffer;
  7358. /** @hidden */
  7359. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7360. private _currentBufferPointers;
  7361. private _currentInstanceLocations;
  7362. private _currentInstanceBuffers;
  7363. private _textureUnits;
  7364. private _firstBoundInternalTextureTracker;
  7365. private _lastBoundInternalTextureTracker;
  7366. private _workingCanvas;
  7367. private _workingContext;
  7368. private _rescalePostProcess;
  7369. private _dummyFramebuffer;
  7370. private _externalData;
  7371. private _bindedRenderFunction;
  7372. private _vaoRecordInProgress;
  7373. private _mustWipeVertexAttributes;
  7374. private _emptyTexture;
  7375. private _emptyCubeTexture;
  7376. private _emptyTexture3D;
  7377. private _frameHandler;
  7378. private _nextFreeTextureSlots;
  7379. private _maxSimultaneousTextures;
  7380. private _activeRequests;
  7381. private _texturesSupported;
  7382. private _textureFormatInUse;
  7383. /**
  7384. * Gets the list of texture formats supported
  7385. */
  7386. readonly texturesSupported: Array<string>;
  7387. /**
  7388. * Gets the list of texture formats in use
  7389. */
  7390. readonly textureFormatInUse: Nullable<string>;
  7391. /**
  7392. * Gets the current viewport
  7393. */
  7394. readonly currentViewport: Nullable<Viewport>;
  7395. /**
  7396. * Gets the default empty texture
  7397. */
  7398. readonly emptyTexture: InternalTexture;
  7399. /**
  7400. * Gets the default empty 3D texture
  7401. */
  7402. readonly emptyTexture3D: InternalTexture;
  7403. /**
  7404. * Gets the default empty cube texture
  7405. */
  7406. readonly emptyCubeTexture: InternalTexture;
  7407. /**
  7408. * Creates a new engine
  7409. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7410. * @param antialias defines enable antialiasing (default: false)
  7411. * @param options defines further options to be sent to the getContext() function
  7412. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7413. */
  7414. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7415. private _rebuildInternalTextures();
  7416. private _rebuildEffects();
  7417. private _rebuildBuffers();
  7418. private _initGLContext();
  7419. /**
  7420. * Gets version of the current webGL context
  7421. */
  7422. readonly webGLVersion: number;
  7423. /**
  7424. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7425. */
  7426. readonly isStencilEnable: boolean;
  7427. private _prepareWorkingCanvas();
  7428. /**
  7429. * Reset the texture cache to empty state
  7430. */
  7431. resetTextureCache(): void;
  7432. /**
  7433. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7434. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7435. * @returns true if engine is in deterministic lock step mode
  7436. */
  7437. isDeterministicLockStep(): boolean;
  7438. /**
  7439. * Gets the max steps when engine is running in deterministic lock step
  7440. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7441. * @returns the max steps
  7442. */
  7443. getLockstepMaxSteps(): number;
  7444. /**
  7445. * Gets an object containing information about the current webGL context
  7446. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7447. */
  7448. getGlInfo(): {
  7449. vendor: string;
  7450. renderer: string;
  7451. version: string;
  7452. };
  7453. /**
  7454. * Gets current aspect ratio
  7455. * @param camera defines the camera to use to get the aspect ratio
  7456. * @param useScreen defines if screen size must be used (or the current render target if any)
  7457. * @returns a number defining the aspect ratio
  7458. */
  7459. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7460. /**
  7461. * Gets current screen aspect ratio
  7462. * @returns a number defining the aspect ratio
  7463. */
  7464. getScreenAspectRatio(): number;
  7465. /**
  7466. * Gets the current render width
  7467. * @param useScreen defines if screen size must be used (or the current render target if any)
  7468. * @returns a number defining the current render width
  7469. */
  7470. getRenderWidth(useScreen?: boolean): number;
  7471. /**
  7472. * Gets the current render height
  7473. * @param useScreen defines if screen size must be used (or the current render target if any)
  7474. * @returns a number defining the current render height
  7475. */
  7476. getRenderHeight(useScreen?: boolean): number;
  7477. /**
  7478. * Gets the HTML canvas attached with the current webGL context
  7479. * @returns a HTML canvas
  7480. */
  7481. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7482. /**
  7483. * Gets the client rect of the HTML canvas attached with the current webGL context
  7484. * @returns a client rectanglee
  7485. */
  7486. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7487. /**
  7488. * Defines the hardware scaling level.
  7489. * By default the hardware scaling level is computed from the window device ratio.
  7490. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  7491. * @param level defines the level to use
  7492. */
  7493. setHardwareScalingLevel(level: number): void;
  7494. /**
  7495. * Gets the current hardware scaling level.
  7496. * By default the hardware scaling level is computed from the window device ratio.
  7497. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  7498. * @returns a number indicating the current hardware scaling level
  7499. */
  7500. getHardwareScalingLevel(): number;
  7501. /**
  7502. * Gets the list of loaded textures
  7503. * @returns an array containing all loaded textures
  7504. */
  7505. getLoadedTexturesCache(): InternalTexture[];
  7506. /**
  7507. * Gets the object containing all engine capabilities
  7508. * @returns the EngineCapabilities object
  7509. */
  7510. getCaps(): EngineCapabilities;
  7511. /** @hidden */
  7512. readonly drawCalls: number;
  7513. /** @hidden */
  7514. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7515. /**
  7516. * Gets the current depth function
  7517. * @returns a number defining the depth function
  7518. */
  7519. getDepthFunction(): Nullable<number>;
  7520. /**
  7521. * Sets the current depth function
  7522. * @param depthFunc defines the function to use
  7523. */
  7524. setDepthFunction(depthFunc: number): void;
  7525. /**
  7526. * Sets the current depth function to GREATER
  7527. */
  7528. setDepthFunctionToGreater(): void;
  7529. /**
  7530. * Sets the current depth function to GEQUAL
  7531. */
  7532. setDepthFunctionToGreaterOrEqual(): void;
  7533. /**
  7534. * Sets the current depth function to LESS
  7535. */
  7536. setDepthFunctionToLess(): void;
  7537. /**
  7538. * Sets the current depth function to LEQUAL
  7539. */
  7540. setDepthFunctionToLessOrEqual(): void;
  7541. /**
  7542. * Gets a boolean indicating if stencil buffer is enabled
  7543. * @returns the current stencil buffer state
  7544. */
  7545. getStencilBuffer(): boolean;
  7546. /**
  7547. * Enable or disable the stencil buffer
  7548. * @param enable defines if the stencil buffer must be enabled or disabled
  7549. */
  7550. setStencilBuffer(enable: boolean): void;
  7551. /**
  7552. * Gets the current stencil mask
  7553. * @returns a number defining the new stencil mask to use
  7554. */
  7555. getStencilMask(): number;
  7556. /**
  7557. * Sets the current stencil mask
  7558. * @param mask defines the new stencil mask to use
  7559. */
  7560. setStencilMask(mask: number): void;
  7561. /**
  7562. * Gets the current stencil function
  7563. * @returns a number defining the stencil function to use
  7564. */
  7565. getStencilFunction(): number;
  7566. /**
  7567. * Gets the current stencil reference value
  7568. * @returns a number defining the stencil reference value to use
  7569. */
  7570. getStencilFunctionReference(): number;
  7571. /**
  7572. * Gets the current stencil mask
  7573. * @returns a number defining the stencil mask to use
  7574. */
  7575. getStencilFunctionMask(): number;
  7576. /**
  7577. * Sets the current stencil function
  7578. * @param stencilFunc defines the new stencil function to use
  7579. */
  7580. setStencilFunction(stencilFunc: number): void;
  7581. /**
  7582. * Sets the current stencil reference
  7583. * @param reference defines the new stencil reference to use
  7584. */
  7585. setStencilFunctionReference(reference: number): void;
  7586. /**
  7587. * Sets the current stencil mask
  7588. * @param mask defines the new stencil mask to use
  7589. */
  7590. setStencilFunctionMask(mask: number): void;
  7591. /**
  7592. * Gets the current stencil operation when stencil fails
  7593. * @returns a number defining stencil operation to use when stencil fails
  7594. */
  7595. getStencilOperationFail(): number;
  7596. /**
  7597. * Gets the current stencil operation when depth fails
  7598. * @returns a number defining stencil operation to use when depth fails
  7599. */
  7600. getStencilOperationDepthFail(): number;
  7601. /**
  7602. * Gets the current stencil operation when stencil passes
  7603. * @returns a number defining stencil operation to use when stencil passes
  7604. */
  7605. getStencilOperationPass(): number;
  7606. /**
  7607. * Sets the stencil operation to use when stencil fails
  7608. * @param operation defines the stencil operation to use when stencil fails
  7609. */
  7610. setStencilOperationFail(operation: number): void;
  7611. /**
  7612. * Sets the stencil operation to use when depth fails
  7613. * @param operation defines the stencil operation to use when depth fails
  7614. */
  7615. setStencilOperationDepthFail(operation: number): void;
  7616. /**
  7617. * Sets the stencil operation to use when stencil passes
  7618. * @param operation defines the stencil operation to use when stencil passes
  7619. */
  7620. setStencilOperationPass(operation: number): void;
  7621. /**
  7622. * Sets a boolean indicating if the dithering state is enabled or disabled
  7623. * @param value defines the dithering state
  7624. */
  7625. setDitheringState(value: boolean): void;
  7626. /**
  7627. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7628. * @param value defines the rasterizer state
  7629. */
  7630. setRasterizerState(value: boolean): void;
  7631. /**
  7632. * stop executing a render loop function and remove it from the execution array
  7633. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7634. */
  7635. stopRenderLoop(renderFunction?: () => void): void;
  7636. /** @hidden */
  7637. _renderLoop(): void;
  7638. /**
  7639. * Register and execute a render loop. The engine can have more than one render function
  7640. * @param renderFunction defines the function to continuously execute
  7641. */
  7642. runRenderLoop(renderFunction: () => void): void;
  7643. /**
  7644. * Toggle full screen mode
  7645. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7646. * @param options defines an option object to be sent to the requestFullscreen function
  7647. */
  7648. switchFullscreen(requestPointerLock: boolean): void;
  7649. /**
  7650. * Clear the current render buffer or the current render target (if any is set up)
  7651. * @param color defines the color to use
  7652. * @param backBuffer defines if the back buffer must be cleared
  7653. * @param depth defines if the depth buffer must be cleared
  7654. * @param stencil defines if the stencil buffer must be cleared
  7655. */
  7656. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7657. /**
  7658. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7659. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7660. * @param y defines the y-coordinate of the corner of the clear rectangle
  7661. * @param width defines the width of the clear rectangle
  7662. * @param height defines the height of the clear rectangle
  7663. * @param clearColor defines the clear color
  7664. */
  7665. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7666. /**
  7667. * Set the WebGL's viewport
  7668. * @param viewport defines the viewport element to be used
  7669. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7670. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7671. */
  7672. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7673. /**
  7674. * Directly set the WebGL Viewport
  7675. * @param x defines the x coordinate of the viewport (in screen space)
  7676. * @param y defines the y coordinate of the viewport (in screen space)
  7677. * @param width defines the width of the viewport (in screen space)
  7678. * @param height defines the height of the viewport (in screen space)
  7679. * @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
  7680. */
  7681. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7682. /**
  7683. * Begin a new frame
  7684. */
  7685. beginFrame(): void;
  7686. /**
  7687. * Enf the current frame
  7688. */
  7689. endFrame(): void;
  7690. /**
  7691. * Resize the view according to the canvas' size
  7692. */
  7693. resize(): void;
  7694. /**
  7695. * Force a specific size of the canvas
  7696. * @param width defines the new canvas' width
  7697. * @param height defines the new canvas' height
  7698. */
  7699. setSize(width: number, height: number): void;
  7700. /**
  7701. * Gets a boolean indicating if a webVR device was detected
  7702. * @returns true if a webVR device was detected
  7703. */
  7704. isVRDevicePresent(): boolean;
  7705. /**
  7706. * Gets the current webVR device
  7707. * @returns the current webVR device (or null)
  7708. */
  7709. getVRDevice(): any;
  7710. /**
  7711. * Initializes a webVR display and starts listening to display change events
  7712. * The onVRDisplayChangedObservable will be notified upon these changes
  7713. * @returns The onVRDisplayChangedObservable
  7714. */
  7715. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7716. /**
  7717. * Initializes a webVR display and starts listening to display change events
  7718. * The onVRDisplayChangedObservable will be notified upon these changes
  7719. * @returns A promise containing a VRDisplay and if vr is supported
  7720. */
  7721. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7722. /**
  7723. * Call this function to switch to webVR mode
  7724. * Will do nothing if webVR is not supported or if there is no webVR device
  7725. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7726. */
  7727. enableVR(): void;
  7728. /**
  7729. * Call this function to leave webVR mode
  7730. * Will do nothing if webVR is not supported or if there is no webVR device
  7731. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7732. */
  7733. disableVR(): void;
  7734. private _onVRFullScreenTriggered;
  7735. private _getVRDisplaysAsync();
  7736. /**
  7737. * Binds the frame buffer to the specified texture.
  7738. * @param texture The texture to render to or null for the default canvas
  7739. * @param faceIndex The face of the texture to render to in case of cube texture
  7740. * @param requiredWidth The width of the target to render to
  7741. * @param requiredHeight The height of the target to render to
  7742. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7743. * @param depthStencilTexture The depth stencil texture to use to render
  7744. */
  7745. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  7746. private bindUnboundFramebuffer(framebuffer);
  7747. /**
  7748. * Unbind the current render target texture from the webGL context
  7749. * @param texture defines the render target texture to unbind
  7750. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7751. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7752. */
  7753. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7754. /**
  7755. * Unbind a list of render target textures from the webGL context
  7756. * This is used only when drawBuffer extension or webGL2 are active
  7757. * @param textures defines the render target textures to unbind
  7758. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7759. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7760. */
  7761. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7762. /**
  7763. * Force the mipmap generation for the given render target texture
  7764. * @param texture defines the render target texture to use
  7765. */
  7766. generateMipMapsForCubemap(texture: InternalTexture): void;
  7767. /**
  7768. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7769. */
  7770. flushFramebuffer(): void;
  7771. /**
  7772. * Unbind the current render target and bind the default framebuffer
  7773. */
  7774. restoreDefaultFramebuffer(): void;
  7775. /**
  7776. * Create an uniform buffer
  7777. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7778. * @param elements defines the content of the uniform buffer
  7779. * @returns the webGL uniform buffer
  7780. */
  7781. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7782. /**
  7783. * Create a dynamic uniform buffer
  7784. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7785. * @param elements defines the content of the uniform buffer
  7786. * @returns the webGL uniform buffer
  7787. */
  7788. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7789. /**
  7790. * Update an existing uniform buffer
  7791. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7792. * @param uniformBuffer defines the target uniform buffer
  7793. * @param elements defines the content to update
  7794. * @param offset defines the offset in the uniform buffer where update should start
  7795. * @param count defines the size of the data to update
  7796. */
  7797. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7798. private _resetVertexBufferBinding();
  7799. /**
  7800. * Creates a vertex buffer
  7801. * @param data the data for the vertex buffer
  7802. * @returns the new WebGL static buffer
  7803. */
  7804. createVertexBuffer(data: DataArray): WebGLBuffer;
  7805. /**
  7806. * Creates a dynamic vertex buffer
  7807. * @param data the data for the dynamic vertex buffer
  7808. * @returns the new WebGL dynamic buffer
  7809. */
  7810. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7811. /**
  7812. * Update a dynamic index buffer
  7813. * @param indexBuffer defines the target index buffer
  7814. * @param indices defines the data to update
  7815. * @param offset defines the offset in the target index buffer where update should start
  7816. */
  7817. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7818. /**
  7819. * Updates a dynamic vertex buffer.
  7820. * @param vertexBuffer the vertex buffer to update
  7821. * @param data the data used to update the vertex buffer
  7822. * @param byteOffset the byte offset of the data
  7823. * @param byteLength the byte length of the data
  7824. */
  7825. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7826. private _resetIndexBufferBinding();
  7827. /**
  7828. * Creates a new index buffer
  7829. * @param indices defines the content of the index buffer
  7830. * @param updatable defines if the index buffer must be updatable
  7831. * @returns a new webGL buffer
  7832. */
  7833. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7834. /**
  7835. * Bind a webGL buffer to the webGL context
  7836. * @param buffer defines the buffer to bind
  7837. */
  7838. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7839. /**
  7840. * Bind an uniform buffer to the current webGL context
  7841. * @param buffer defines the buffer to bind
  7842. */
  7843. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7844. /**
  7845. * Bind a buffer to the current webGL context at a given location
  7846. * @param buffer defines the buffer to bind
  7847. * @param location defines the index where to bind the buffer
  7848. */
  7849. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7850. /**
  7851. * Bind a specific block at a given index in a specific shader program
  7852. * @param shaderProgram defines the shader program
  7853. * @param blockName defines the block name
  7854. * @param index defines the index where to bind the block
  7855. */
  7856. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7857. private bindIndexBuffer(buffer);
  7858. private bindBuffer(buffer, target);
  7859. /**
  7860. * update the bound buffer with the given data
  7861. * @param data defines the data to update
  7862. */
  7863. updateArrayBuffer(data: Float32Array): void;
  7864. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7865. private _bindIndexBufferWithCache(indexBuffer);
  7866. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7867. /**
  7868. * Records a vertex array object
  7869. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7870. * @param vertexBuffers defines the list of vertex buffers to store
  7871. * @param indexBuffer defines the index buffer to store
  7872. * @param effect defines the effect to store
  7873. * @returns the new vertex array object
  7874. */
  7875. recordVertexArrayObject(vertexBuffers: {
  7876. [key: string]: VertexBuffer;
  7877. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7878. /**
  7879. * Bind a specific vertex array object
  7880. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7881. * @param vertexArrayObject defines the vertex array object to bind
  7882. * @param indexBuffer defines the index buffer to bind
  7883. */
  7884. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7885. /**
  7886. * Bind webGl buffers directly to the webGL context
  7887. * @param vertexBuffer defines the vertex buffer to bind
  7888. * @param indexBuffer defines the index buffer to bind
  7889. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7890. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7891. * @param effect defines the effect associated with the vertex buffer
  7892. */
  7893. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7894. private _unbindVertexArrayObject();
  7895. /**
  7896. * Bind a list of vertex buffers to the webGL context
  7897. * @param vertexBuffers defines the list of vertex buffers to bind
  7898. * @param indexBuffer defines the index buffer to bind
  7899. * @param effect defines the effect associated with the vertex buffers
  7900. */
  7901. bindBuffers(vertexBuffers: {
  7902. [key: string]: Nullable<VertexBuffer>;
  7903. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7904. /**
  7905. * Unbind all instance attributes
  7906. */
  7907. unbindInstanceAttributes(): void;
  7908. /**
  7909. * Release and free the memory of a vertex array object
  7910. * @param vao defines the vertex array object to delete
  7911. */
  7912. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7913. /** @hidden */
  7914. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7915. /**
  7916. * Creates a webGL buffer to use with instanciation
  7917. * @param capacity defines the size of the buffer
  7918. * @returns the webGL buffer
  7919. */
  7920. createInstancesBuffer(capacity: number): WebGLBuffer;
  7921. /**
  7922. * Delete a webGL buffer used with instanciation
  7923. * @param buffer defines the webGL buffer to delete
  7924. */
  7925. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7926. /**
  7927. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7928. * @param instancesBuffer defines the webGL buffer to update and bind
  7929. * @param data defines the data to store in the buffer
  7930. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7931. */
  7932. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7933. /**
  7934. * Apply all cached states (depth, culling, stencil and alpha)
  7935. */
  7936. applyStates(): void;
  7937. /**
  7938. * Send a draw order
  7939. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7940. * @param indexStart defines the starting index
  7941. * @param indexCount defines the number of index to draw
  7942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7943. */
  7944. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7945. /**
  7946. * Draw a list of points
  7947. * @param verticesStart defines the index of first vertex to draw
  7948. * @param verticesCount defines the count of vertices to draw
  7949. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7950. */
  7951. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7952. /**
  7953. * Draw a list of unindexed primitives
  7954. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7955. * @param verticesStart defines the index of first vertex to draw
  7956. * @param verticesCount defines the count of vertices to draw
  7957. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7958. */
  7959. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7960. /**
  7961. * Draw a list of indexed primitives
  7962. * @param fillMode defines the primitive to use
  7963. * @param indexStart defines the starting index
  7964. * @param indexCount defines the number of index to draw
  7965. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7966. */
  7967. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7968. /**
  7969. * Draw a list of unindexed primitives
  7970. * @param fillMode defines the primitive to use
  7971. * @param verticesStart defines the index of first vertex to draw
  7972. * @param verticesCount defines the count of vertices to draw
  7973. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7974. */
  7975. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7976. private _drawMode(fillMode);
  7977. /** @hidden */
  7978. _releaseEffect(effect: Effect): void;
  7979. /** @hidden */
  7980. _deleteProgram(program: WebGLProgram): void;
  7981. /**
  7982. * Create a new effect (used to store vertex/fragment shaders)
  7983. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7984. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7985. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7986. * @param samplers defines an array of string used to represent textures
  7987. * @param defines defines the string containing the defines to use to compile the shaders
  7988. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7989. * @param onCompiled defines a function to call when the effect creation is successful
  7990. * @param onError defines a function to call when the effect creation has failed
  7991. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7992. * @returns the new Effect
  7993. */
  7994. 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;
  7995. /**
  7996. * Create an effect to use with particle systems
  7997. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7998. * @param uniformsNames defines a list of attribute names
  7999. * @param samplers defines an array of string used to represent textures
  8000. * @param defines defines the string containing the defines to use to compile the shaders
  8001. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8002. * @param onCompiled defines a function to call when the effect creation is successful
  8003. * @param onError defines a function to call when the effect creation has failed
  8004. * @returns the new Effect
  8005. */
  8006. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8007. /**
  8008. * Directly creates a webGL program
  8009. * @param vertexCode defines the vertex shader code to use
  8010. * @param fragmentCode defines the fragment shader code to use
  8011. * @param context defines the webGL context to use (if not set, the current one will be used)
  8012. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8013. * @returns the new webGL program
  8014. */
  8015. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8016. /**
  8017. * Creates a webGL program
  8018. * @param vertexCode defines the vertex shader code to use
  8019. * @param fragmentCode defines the fragment shader code to use
  8020. * @param defines defines the string containing the defines to use to compile the shaders
  8021. * @param context defines the webGL context to use (if not set, the current one will be used)
  8022. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8023. * @returns the new webGL program
  8024. */
  8025. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8026. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8027. /**
  8028. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8029. * @param shaderProgram defines the webGL program to use
  8030. * @param uniformsNames defines the list of uniform names
  8031. * @returns an array of webGL uniform locations
  8032. */
  8033. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8034. /**
  8035. * Gets the lsit of active attributes for a given webGL program
  8036. * @param shaderProgram defines the webGL program to use
  8037. * @param attributesNames defines the list of attribute names to get
  8038. * @returns an array of indices indicating the offset of each attribute
  8039. */
  8040. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8041. /**
  8042. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8043. * @param effect defines the effect to activate
  8044. */
  8045. enableEffect(effect: Nullable<Effect>): void;
  8046. /**
  8047. * Set the value of an uniform to an array of int32
  8048. * @param uniform defines the webGL uniform location where to store the value
  8049. * @param array defines the array of int32 to store
  8050. */
  8051. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8052. /**
  8053. * Set the value of an uniform to an array of int32 (stored as vec2)
  8054. * @param uniform defines the webGL uniform location where to store the value
  8055. * @param array defines the array of int32 to store
  8056. */
  8057. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8058. /**
  8059. * Set the value of an uniform to an array of int32 (stored as vec3)
  8060. * @param uniform defines the webGL uniform location where to store the value
  8061. * @param array defines the array of int32 to store
  8062. */
  8063. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8064. /**
  8065. * Set the value of an uniform to an array of int32 (stored as vec4)
  8066. * @param uniform defines the webGL uniform location where to store the value
  8067. * @param array defines the array of int32 to store
  8068. */
  8069. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8070. /**
  8071. * Set the value of an uniform to an array of float32
  8072. * @param uniform defines the webGL uniform location where to store the value
  8073. * @param array defines the array of float32 to store
  8074. */
  8075. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8076. /**
  8077. * Set the value of an uniform to an array of float32 (stored as vec2)
  8078. * @param uniform defines the webGL uniform location where to store the value
  8079. * @param array defines the array of float32 to store
  8080. */
  8081. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8082. /**
  8083. * Set the value of an uniform to an array of float32 (stored as vec3)
  8084. * @param uniform defines the webGL uniform location where to store the value
  8085. * @param array defines the array of float32 to store
  8086. */
  8087. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8088. /**
  8089. * Set the value of an uniform to an array of float32 (stored as vec4)
  8090. * @param uniform defines the webGL uniform location where to store the value
  8091. * @param array defines the array of float32 to store
  8092. */
  8093. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8094. /**
  8095. * Set the value of an uniform to an array of number
  8096. * @param uniform defines the webGL uniform location where to store the value
  8097. * @param array defines the array of number to store
  8098. */
  8099. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8100. /**
  8101. * Set the value of an uniform to an array of number (stored as vec2)
  8102. * @param uniform defines the webGL uniform location where to store the value
  8103. * @param array defines the array of number to store
  8104. */
  8105. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8106. /**
  8107. * Set the value of an uniform to an array of number (stored as vec3)
  8108. * @param uniform defines the webGL uniform location where to store the value
  8109. * @param array defines the array of number to store
  8110. */
  8111. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8112. /**
  8113. * Set the value of an uniform to an array of number (stored as vec4)
  8114. * @param uniform defines the webGL uniform location where to store the value
  8115. * @param array defines the array of number to store
  8116. */
  8117. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8118. /**
  8119. * Set the value of an uniform to an array of float32 (stored as matrices)
  8120. * @param uniform defines the webGL uniform location where to store the value
  8121. * @param matrices defines the array of float32 to store
  8122. */
  8123. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8124. /**
  8125. * Set the value of an uniform to a matrix
  8126. * @param uniform defines the webGL uniform location where to store the value
  8127. * @param matrix defines the matrix to store
  8128. */
  8129. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8130. /**
  8131. * Set the value of an uniform to a matrix (3x3)
  8132. * @param uniform defines the webGL uniform location where to store the value
  8133. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8134. */
  8135. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8136. /**
  8137. * Set the value of an uniform to a matrix (2x2)
  8138. * @param uniform defines the webGL uniform location where to store the value
  8139. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8140. */
  8141. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8142. /**
  8143. * Set the value of an uniform to a number (int)
  8144. * @param uniform defines the webGL uniform location where to store the value
  8145. * @param value defines the int number to store
  8146. */
  8147. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8148. /**
  8149. * Set the value of an uniform to a number (float)
  8150. * @param uniform defines the webGL uniform location where to store the value
  8151. * @param value defines the float number to store
  8152. */
  8153. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8154. /**
  8155. * Set the value of an uniform to a vec2
  8156. * @param uniform defines the webGL uniform location where to store the value
  8157. * @param x defines the 1st component of the value
  8158. * @param y defines the 2nd component of the value
  8159. */
  8160. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8161. /**
  8162. * Set the value of an uniform to a vec3
  8163. * @param uniform defines the webGL uniform location where to store the value
  8164. * @param x defines the 1st component of the value
  8165. * @param y defines the 2nd component of the value
  8166. * @param z defines the 3rd component of the value
  8167. */
  8168. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8169. /**
  8170. * Set the value of an uniform to a boolean
  8171. * @param uniform defines the webGL uniform location where to store the value
  8172. * @param bool defines the boolean to store
  8173. */
  8174. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8175. /**
  8176. * Set the value of an uniform to a vec4
  8177. * @param uniform defines the webGL uniform location where to store the value
  8178. * @param x defines the 1st component of the value
  8179. * @param y defines the 2nd component of the value
  8180. * @param z defines the 3rd component of the value
  8181. * @param w defines the 4th component of the value
  8182. */
  8183. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8184. /**
  8185. * Set the value of an uniform to a Color3
  8186. * @param uniform defines the webGL uniform location where to store the value
  8187. * @param color3 defines the color to store
  8188. */
  8189. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8190. /**
  8191. * Set the value of an uniform to a Color3 and an alpha value
  8192. * @param uniform defines the webGL uniform location where to store the value
  8193. * @param color3 defines the color to store
  8194. * @param alpha defines the alpha component to store
  8195. */
  8196. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8197. /**
  8198. * Sets a Color4 on a uniform variable
  8199. * @param uniform defines the uniform location
  8200. * @param color4 defines the value to be set
  8201. */
  8202. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8203. /**
  8204. * Set various states to the webGL context
  8205. * @param culling defines backface culling state
  8206. * @param zOffset defines the value to apply to zOffset (0 by default)
  8207. * @param force defines if states must be applied even if cache is up to date
  8208. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8209. */
  8210. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8211. /**
  8212. * Set the z offset to apply to current rendering
  8213. * @param value defines the offset to apply
  8214. */
  8215. setZOffset(value: number): void;
  8216. /**
  8217. * Gets the current value of the zOffset
  8218. * @returns the current zOffset state
  8219. */
  8220. getZOffset(): number;
  8221. /**
  8222. * Enable or disable depth buffering
  8223. * @param enable defines the state to set
  8224. */
  8225. setDepthBuffer(enable: boolean): void;
  8226. /**
  8227. * Gets a boolean indicating if depth writing is enabled
  8228. * @returns the current depth writing state
  8229. */
  8230. getDepthWrite(): boolean;
  8231. /**
  8232. * Enable or disable depth writing
  8233. * @param enable defines the state to set
  8234. */
  8235. setDepthWrite(enable: boolean): void;
  8236. /**
  8237. * Enable or disable color writing
  8238. * @param enable defines the state to set
  8239. */
  8240. setColorWrite(enable: boolean): void;
  8241. /**
  8242. * Gets a boolean indicating if color writing is enabled
  8243. * @returns the current color writing state
  8244. */
  8245. getColorWrite(): boolean;
  8246. /**
  8247. * Sets alpha constants used by some alpha blending modes
  8248. * @param r defines the red component
  8249. * @param g defines the green component
  8250. * @param b defines the blue component
  8251. * @param a defines the alpha component
  8252. */
  8253. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8254. /**
  8255. * Sets the current alpha mode
  8256. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8257. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8258. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8259. */
  8260. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8261. /**
  8262. * Gets the current alpha mode
  8263. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8264. * @returns the current alpha mode
  8265. */
  8266. getAlphaMode(): number;
  8267. /**
  8268. * Force the entire cache to be cleared
  8269. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8270. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8271. */
  8272. wipeCaches(bruteForce?: boolean): void;
  8273. /**
  8274. * Set the compressed texture format to use, based on the formats you have, and the formats
  8275. * supported by the hardware / browser.
  8276. *
  8277. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8278. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8279. * to API arguments needed to compressed textures. This puts the burden on the container
  8280. * generator to house the arcane code for determining these for current & future formats.
  8281. *
  8282. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8283. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8284. *
  8285. * Note: The result of this call is not taken into account when a texture is base64.
  8286. *
  8287. * @param formatsAvailable defines the list of those format families you have created
  8288. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8289. *
  8290. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8291. * @returns The extension selected.
  8292. */
  8293. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8294. /** @hidden */
  8295. _createTexture(): WebGLTexture;
  8296. /**
  8297. * Usually called from BABYLON.Texture.ts.
  8298. * Passed information to create a WebGLTexture
  8299. * @param urlArg defines a value which contains one of the following:
  8300. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8301. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8302. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8303. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8304. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8305. * @param scene needed for loading to the correct scene
  8306. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8307. * @param onLoad optional callback to be called upon successful completion
  8308. * @param onError optional callback to be called upon failure
  8309. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  8310. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8311. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8312. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8313. */
  8314. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8315. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8316. /**
  8317. * Update a raw texture
  8318. * @param texture defines the texture to update
  8319. * @param data defines the data to store in the texture
  8320. * @param format defines the format of the data
  8321. * @param invertY defines if data must be stored with Y axis inverted
  8322. * @param compression defines the compression used (null by default)
  8323. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8324. */
  8325. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8326. /**
  8327. * Creates a raw texture
  8328. * @param data defines the data to store in the texture
  8329. * @param width defines the width of the texture
  8330. * @param height defines the height of the texture
  8331. * @param format defines the format of the data
  8332. * @param generateMipMaps defines if the engine should generate the mip levels
  8333. * @param invertY defines if data must be stored with Y axis inverted
  8334. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8335. * @param compression defines the compression used (null by default)
  8336. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8337. * @returns the raw texture inside an InternalTexture
  8338. */
  8339. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8340. /**
  8341. * Creates a dynamic texture
  8342. * @param width defines the width of the texture
  8343. * @param height defines the height of the texture
  8344. * @param generateMipMaps defines if the engine should generate the mip levels
  8345. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8346. * @returns the dynamic texture inside an InternalTexture
  8347. */
  8348. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8349. /**
  8350. * Update the sampling mode of a given texture
  8351. * @param samplingMode defines the required sampling mode
  8352. * @param texture defines the texture to update
  8353. */
  8354. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8355. /**
  8356. * Update the content of a dynamic texture
  8357. * @param texture defines the texture to update
  8358. * @param canvas defines the canvas containing the source
  8359. * @param invertY defines if data must be stored with Y axis inverted
  8360. * @param premulAlpha defines if alpha is stored as premultiplied
  8361. * @param format defines the format of the data
  8362. */
  8363. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8364. /**
  8365. * Update a video texture
  8366. * @param texture defines the texture to update
  8367. * @param video defines the video element to use
  8368. * @param invertY defines if data must be stored with Y axis inverted
  8369. */
  8370. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8371. /**
  8372. * Updates a depth texture Comparison Mode and Function.
  8373. * If the comparison Function is equal to 0, the mode will be set to none.
  8374. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8375. * @param texture The texture to set the comparison function for
  8376. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8377. */
  8378. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8379. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8380. /**
  8381. * Creates a depth stencil texture.
  8382. * This is only available in WebGL 2 or with the depth texture extension available.
  8383. * @param size The size of face edge in the texture.
  8384. * @param options The options defining the texture.
  8385. * @returns The texture
  8386. */
  8387. createDepthStencilTexture(size: number | {
  8388. width: number;
  8389. height: number;
  8390. }, options: DepthTextureCreationOptions): InternalTexture;
  8391. /**
  8392. * Creates a depth stencil texture.
  8393. * This is only available in WebGL 2 or with the depth texture extension available.
  8394. * @param size The size of face edge in the texture.
  8395. * @param options The options defining the texture.
  8396. * @returns The texture
  8397. */
  8398. private _createDepthStencilTexture(size, options);
  8399. /**
  8400. * Creates a depth stencil cube texture.
  8401. * This is only available in WebGL 2.
  8402. * @param size The size of face edge in the cube texture.
  8403. * @param options The options defining the cube texture.
  8404. * @returns The cube texture
  8405. */
  8406. private _createDepthStencilCubeTexture(size, options);
  8407. /**
  8408. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8409. * @param renderTarget The render target to set the frame buffer for
  8410. */
  8411. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8412. /**
  8413. * Creates a new render target texture
  8414. * @param size defines the size of the texture
  8415. * @param options defines the options used to create the texture
  8416. * @returns a new render target texture stored in an InternalTexture
  8417. */
  8418. createRenderTargetTexture(size: number | {
  8419. width: number;
  8420. height: number;
  8421. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8422. /**
  8423. * Create a multi render target texture
  8424. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8425. * @param size defines the size of the texture
  8426. * @param options defines the creation options
  8427. * @returns the cube texture as an InternalTexture
  8428. */
  8429. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8430. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8431. /**
  8432. * Updates the sample count of a render target texture
  8433. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8434. * @param texture defines the texture to update
  8435. * @param samples defines the sample count to set
  8436. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8437. */
  8438. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8439. /**
  8440. * Update the sample count for a given multiple render target texture
  8441. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8442. * @param textures defines the textures to update
  8443. * @param samples defines the sample count to set
  8444. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8445. */
  8446. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8447. /** @hidden */
  8448. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8449. /** @hidden */
  8450. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8451. /**
  8452. * Creates a new render target cube texture
  8453. * @param size defines the size of the texture
  8454. * @param options defines the options used to create the texture
  8455. * @returns a new render target cube texture stored in an InternalTexture
  8456. */
  8457. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8458. /**
  8459. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8460. * @param rootUrl defines the url where the file to load is located
  8461. * @param scene defines the current scene
  8462. * @param scale defines scale to apply to the mip map selection
  8463. * @param offset defines offset to apply to the mip map selection
  8464. * @param onLoad defines an optional callback raised when the texture is loaded
  8465. * @param onError defines an optional callback raised if there is an issue to load the texture
  8466. * @param format defines the format of the data
  8467. * @param forcedExtension defines the extension to use to pick the right loader
  8468. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8469. * @returns the cube texture as an InternalTexture
  8470. */
  8471. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8472. /**
  8473. * Creates a cube texture
  8474. * @param rootUrl defines the url where the files to load is located
  8475. * @param scene defines the current scene
  8476. * @param files defines the list of files to load (1 per face)
  8477. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8478. * @param onLoad defines an optional callback raised when the texture is loaded
  8479. * @param onError defines an optional callback raised if there is an issue to load the texture
  8480. * @param format defines the format of the data
  8481. * @param forcedExtension defines the extension to use to pick the right loader
  8482. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8483. * @returns the cube texture as an InternalTexture
  8484. */
  8485. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8486. private setCubeMapTextureParams(gl, loadMipmap);
  8487. /**
  8488. * Update a raw cube texture
  8489. * @param texture defines the texture to udpdate
  8490. * @param data defines the data to store
  8491. * @param format defines the data format
  8492. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8493. * @param invertY defines if data must be stored with Y axis inverted
  8494. * @param compression defines the compression used (null by default)
  8495. * @param level defines which level of the texture to update
  8496. */
  8497. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8498. /**
  8499. * Creates a new raw cube texture
  8500. * @param data defines the array of data to use to create each face
  8501. * @param size defines the size of the textures
  8502. * @param format defines the format of the data
  8503. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8504. * @param generateMipMaps defines if the engine should generate the mip levels
  8505. * @param invertY defines if data must be stored with Y axis inverted
  8506. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8507. * @param compression defines the compression used (null by default)
  8508. * @returns the cube texture as an InternalTexture
  8509. */
  8510. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8511. /**
  8512. * Creates a new raw cube texture from a specified url
  8513. * @param url defines the url where the data is located
  8514. * @param scene defines the current scene
  8515. * @param size defines the size of the textures
  8516. * @param format defines the format of the data
  8517. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8518. * @param noMipmap defines if the engine should avoid generating the mip levels
  8519. * @param callback defines a callback used to extract texture data from loaded data
  8520. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8521. * @param onLoad defines a callback called when texture is loaded
  8522. * @param onError defines a callback called if there is an error
  8523. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8524. * @param invertY defines if data must be stored with Y axis inverted
  8525. * @returns the cube texture as an InternalTexture
  8526. */
  8527. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  8528. /**
  8529. * Update a raw 3D texture
  8530. * @param texture defines the texture to update
  8531. * @param data defines the data to store
  8532. * @param format defines the data format
  8533. * @param invertY defines if data must be stored with Y axis inverted
  8534. * @param compression defines the used compression (can be null)
  8535. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8536. */
  8537. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8538. /**
  8539. * Creates a new raw 3D texture
  8540. * @param data defines the data used to create the texture
  8541. * @param width defines the width of the texture
  8542. * @param height defines the height of the texture
  8543. * @param depth defines the depth of the texture
  8544. * @param format defines the format of the texture
  8545. * @param generateMipMaps defines if the engine must generate mip levels
  8546. * @param invertY defines if data must be stored with Y axis inverted
  8547. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8548. * @param compression defines the compressed used (can be null)
  8549. * @param textureType defines the compressed used (can be null)
  8550. * @returns a new raw 3D texture (stored in an InternalTexture)
  8551. */
  8552. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8553. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8554. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8555. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8556. /** @hidden */
  8557. _releaseFramebufferObjects(texture: InternalTexture): void;
  8558. /** @hidden */
  8559. _releaseTexture(texture: InternalTexture): void;
  8560. private setProgram(program);
  8561. private _boundUniforms;
  8562. /**
  8563. * Binds an effect to the webGL context
  8564. * @param effect defines the effect to bind
  8565. */
  8566. bindSamplers(effect: Effect): void;
  8567. private _moveBoundTextureOnTop(internalTexture);
  8568. private _getCorrectTextureChannel(channel, internalTexture);
  8569. private _linkTrackers(previous, next);
  8570. private _removeDesignatedSlot(internalTexture);
  8571. private _activateCurrentTexture();
  8572. /** @hidden */
  8573. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  8574. /** @hidden */
  8575. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8576. /**
  8577. * Sets a texture to the webGL context from a postprocess
  8578. * @param channel defines the channel to use
  8579. * @param postProcess defines the source postprocess
  8580. */
  8581. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8582. /**
  8583. * Binds the output of the passed in post process to the texture channel specified
  8584. * @param channel The channel the texture should be bound to
  8585. * @param postProcess The post process which's output should be bound
  8586. */
  8587. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8588. /**
  8589. * Unbind all textures from the webGL context
  8590. */
  8591. unbindAllTextures(): void;
  8592. /**
  8593. * Sets a texture to the according uniform.
  8594. * @param channel The texture channel
  8595. * @param uniform The uniform to set
  8596. * @param texture The texture to apply
  8597. */
  8598. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8599. /**
  8600. * Sets a depth stencil texture from a render target to the according uniform.
  8601. * @param channel The texture channel
  8602. * @param uniform The uniform to set
  8603. * @param texture The render target texture containing the depth stencil texture to apply
  8604. */
  8605. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8606. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8607. private _getTextureWrapMode(mode);
  8608. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8609. /**
  8610. * Sets an array of texture to the webGL context
  8611. * @param channel defines the channel where the texture array must be set
  8612. * @param uniform defines the associated uniform location
  8613. * @param textures defines the array of textures to bind
  8614. */
  8615. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8616. /** @hidden */
  8617. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8618. private _setTextureParameterFloat(target, parameter, value, texture);
  8619. private _setTextureParameterInteger(target, parameter, value, texture?);
  8620. /**
  8621. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8622. * @param x defines the x coordinate of the rectangle where pixels must be read
  8623. * @param y defines the y coordinate of the rectangle where pixels must be read
  8624. * @param width defines the width of the rectangle where pixels must be read
  8625. * @param height defines the height of the rectangle where pixels must be read
  8626. * @returns a Uint8Array containing RGBA colors
  8627. */
  8628. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8629. /**
  8630. * Add an externaly attached data from its key.
  8631. * This method call will fail and return false, if such key already exists.
  8632. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8633. * @param key the unique key that identifies the data
  8634. * @param data the data object to associate to the key for this Engine instance
  8635. * @return true if no such key were already present and the data was added successfully, false otherwise
  8636. */
  8637. addExternalData<T>(key: string, data: T): boolean;
  8638. /**
  8639. * Get an externaly attached data from its key
  8640. * @param key the unique key that identifies the data
  8641. * @return the associated data, if present (can be null), or undefined if not present
  8642. */
  8643. getExternalData<T>(key: string): T;
  8644. /**
  8645. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8646. * @param key the unique key that identifies the data
  8647. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8648. * @return the associated data, can be null if the factory returned null.
  8649. */
  8650. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8651. /**
  8652. * Remove an externaly attached data from the Engine instance
  8653. * @param key the unique key that identifies the data
  8654. * @return true if the data was successfully removed, false if it doesn't exist
  8655. */
  8656. removeExternalData(key: string): boolean;
  8657. /**
  8658. * Unbind all vertex attributes from the webGL context
  8659. */
  8660. unbindAllAttributes(): void;
  8661. /**
  8662. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  8663. */
  8664. releaseEffects(): void;
  8665. /**
  8666. * Dispose and release all associated resources
  8667. */
  8668. dispose(): void;
  8669. /**
  8670. * Display the loading screen
  8671. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8672. */
  8673. displayLoadingUI(): void;
  8674. /**
  8675. * Hide the loading screen
  8676. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8677. */
  8678. hideLoadingUI(): void;
  8679. /**
  8680. * Gets the current loading screen object
  8681. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8682. */
  8683. /**
  8684. * Sets the current loading screen object
  8685. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8686. */
  8687. loadingScreen: ILoadingScreen;
  8688. /**
  8689. * Sets the current loading screen text
  8690. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8691. */
  8692. loadingUIText: string;
  8693. /**
  8694. * Sets the current loading screen background color
  8695. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8696. */
  8697. loadingUIBackgroundColor: string;
  8698. /**
  8699. * Attach a new callback raised when context lost event is fired
  8700. * @param callback defines the callback to call
  8701. */
  8702. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8703. /**
  8704. * Attach a new callback raised when context restored event is fired
  8705. * @param callback defines the callback to call
  8706. */
  8707. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8708. /**
  8709. * Gets the source code of the vertex shader associated with a specific webGL program
  8710. * @param program defines the program to use
  8711. * @returns a string containing the source code of the vertex shader associated with the program
  8712. */
  8713. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8714. /**
  8715. * Gets the source code of the fragment shader associated with a specific webGL program
  8716. * @param program defines the program to use
  8717. * @returns a string containing the source code of the fragment shader associated with the program
  8718. */
  8719. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8720. /**
  8721. * Get the current error code of the webGL context
  8722. * @returns the error code
  8723. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8724. */
  8725. getError(): number;
  8726. /**
  8727. * Gets the current framerate
  8728. * @returns a number representing the framerate
  8729. */
  8730. getFps(): number;
  8731. /**
  8732. * Gets the time spent between current and previous frame
  8733. * @returns a number representing the delta time in ms
  8734. */
  8735. getDeltaTime(): number;
  8736. private _measureFps();
  8737. /** @hidden */
  8738. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  8739. private _canRenderToFloatFramebuffer();
  8740. private _canRenderToHalfFloatFramebuffer();
  8741. private _canRenderToFramebuffer(type);
  8742. /** @hidden */
  8743. _getWebGLTextureType(type: number): number;
  8744. private _getInternalFormat(format);
  8745. /** @hidden */
  8746. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8747. /** @hidden */
  8748. _getRGBAMultiSampleBufferFormat(type: number): number;
  8749. /**
  8750. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8751. * @return the new query
  8752. */
  8753. createQuery(): WebGLQuery;
  8754. /**
  8755. * Delete and release a webGL query
  8756. * @param query defines the query to delete
  8757. * @return the current engine
  8758. */
  8759. deleteQuery(query: WebGLQuery): Engine;
  8760. /**
  8761. * Check if a given query has resolved and got its value
  8762. * @param query defines the query to check
  8763. * @returns true if the query got its value
  8764. */
  8765. isQueryResultAvailable(query: WebGLQuery): boolean;
  8766. /**
  8767. * Gets the value of a given query
  8768. * @param query defines the query to check
  8769. * @returns the value of the query
  8770. */
  8771. getQueryResult(query: WebGLQuery): number;
  8772. /**
  8773. * Initiates an occlusion query
  8774. * @param algorithmType defines the algorithm to use
  8775. * @param query defines the query to use
  8776. * @returns the current engine
  8777. * @see http://doc.babylonjs.com/features/occlusionquery
  8778. */
  8779. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8780. /**
  8781. * Ends an occlusion query
  8782. * @see http://doc.babylonjs.com/features/occlusionquery
  8783. * @param algorithmType defines the algorithm to use
  8784. * @returns the current engine
  8785. */
  8786. endOcclusionQuery(algorithmType: number): Engine;
  8787. private _createTimeQuery();
  8788. private _deleteTimeQuery(query);
  8789. private _getTimeQueryResult(query);
  8790. private _getTimeQueryAvailability(query);
  8791. private _currentNonTimestampToken;
  8792. /**
  8793. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8794. * Please note that only one query can be issued at a time
  8795. * @returns a time token used to track the time span
  8796. */
  8797. startTimeQuery(): Nullable<_TimeToken>;
  8798. /**
  8799. * Ends a time query
  8800. * @param token defines the token used to measure the time span
  8801. * @returns the time spent (in ns)
  8802. */
  8803. endTimeQuery(token: _TimeToken): int;
  8804. private getGlAlgorithmType(algorithmType);
  8805. /**
  8806. * Creates a webGL transform feedback object
  8807. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8808. * @returns the webGL transform feedback object
  8809. */
  8810. createTransformFeedback(): WebGLTransformFeedback;
  8811. /**
  8812. * Delete a webGL transform feedback object
  8813. * @param value defines the webGL transform feedback object to delete
  8814. */
  8815. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8816. /**
  8817. * Bind a webGL transform feedback object to the webgl context
  8818. * @param value defines the webGL transform feedback object to bind
  8819. */
  8820. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8821. /**
  8822. * Begins a transform feedback operation
  8823. * @param usePoints defines if points or triangles must be used
  8824. */
  8825. beginTransformFeedback(usePoints?: boolean): void;
  8826. /**
  8827. * Ends a transform feedback operation
  8828. */
  8829. endTransformFeedback(): void;
  8830. /**
  8831. * Specify the varyings to use with transform feedback
  8832. * @param program defines the associated webGL program
  8833. * @param value defines the list of strings representing the varying names
  8834. */
  8835. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8836. /**
  8837. * Bind a webGL buffer for a transform feedback operation
  8838. * @param value defines the webGL buffer to bind
  8839. */
  8840. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8841. /** @hidden */
  8842. _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;
  8843. /** @hidden */
  8844. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8845. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8846. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8847. /**
  8848. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8849. * @returns true if the engine can be created
  8850. * @ignorenaming
  8851. */
  8852. static isSupported(): boolean;
  8853. }
  8854. }
  8855. declare module BABYLON {
  8856. class NullEngineOptions {
  8857. renderWidth: number;
  8858. renderHeight: number;
  8859. textureSize: number;
  8860. deterministicLockstep: boolean;
  8861. lockstepMaxSteps: number;
  8862. }
  8863. /**
  8864. * The null engine class provides support for headless version of babylon.js.
  8865. * This can be used in server side scenario or for testing purposes
  8866. */
  8867. class NullEngine extends Engine {
  8868. private _options;
  8869. isDeterministicLockStep(): boolean;
  8870. getLockstepMaxSteps(): number;
  8871. getHardwareScalingLevel(): number;
  8872. constructor(options?: NullEngineOptions);
  8873. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8874. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8875. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8876. getRenderWidth(useScreen?: boolean): number;
  8877. getRenderHeight(useScreen?: boolean): number;
  8878. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8879. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8880. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8881. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8882. bindSamplers(effect: Effect): void;
  8883. enableEffect(effect: Effect): void;
  8884. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8885. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8886. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8887. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8888. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8889. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8890. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8891. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8892. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8893. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8894. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8895. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8896. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8897. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8898. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8899. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8900. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8901. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8902. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8903. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8904. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8905. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8906. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8907. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8908. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8909. bindBuffers(vertexBuffers: {
  8910. [key: string]: VertexBuffer;
  8911. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8912. wipeCaches(bruteForce?: boolean): void;
  8913. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8914. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8915. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8916. _createTexture(): WebGLTexture;
  8917. _releaseTexture(texture: InternalTexture): void;
  8918. 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;
  8919. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8920. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8921. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8922. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8923. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8924. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8925. /**
  8926. * Updates a dynamic vertex buffer.
  8927. * @param vertexBuffer the vertex buffer to update
  8928. * @param data the data used to update the vertex buffer
  8929. * @param byteOffset the byte offset of the data (optional)
  8930. * @param byteLength the byte length of the data (optional)
  8931. */
  8932. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8933. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8934. _bindTexture(channel: number, texture: InternalTexture): void;
  8935. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8936. releaseEffects(): void;
  8937. }
  8938. }
  8939. interface WebGLRenderingContext {
  8940. readonly RASTERIZER_DISCARD: number;
  8941. readonly DEPTH_COMPONENT24: number;
  8942. readonly TEXTURE_3D: number;
  8943. readonly TEXTURE_2D_ARRAY: number;
  8944. readonly TEXTURE_COMPARE_FUNC: number;
  8945. readonly TEXTURE_COMPARE_MODE: number;
  8946. readonly COMPARE_REF_TO_TEXTURE: number;
  8947. readonly TEXTURE_WRAP_R: number;
  8948. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8949. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8950. 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;
  8951. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8952. readonly TRANSFORM_FEEDBACK: number;
  8953. readonly INTERLEAVED_ATTRIBS: number;
  8954. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8955. createTransformFeedback(): WebGLTransformFeedback;
  8956. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8957. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8958. beginTransformFeedback(primitiveMode: number): void;
  8959. endTransformFeedback(): void;
  8960. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8961. }
  8962. interface ImageBitmap {
  8963. readonly width: number;
  8964. readonly height: number;
  8965. close(): void;
  8966. }
  8967. interface WebGLQuery extends WebGLObject {
  8968. }
  8969. declare var WebGLQuery: {
  8970. prototype: WebGLQuery;
  8971. new (): WebGLQuery;
  8972. };
  8973. interface WebGLSampler extends WebGLObject {
  8974. }
  8975. declare var WebGLSampler: {
  8976. prototype: WebGLSampler;
  8977. new (): WebGLSampler;
  8978. };
  8979. interface WebGLSync extends WebGLObject {
  8980. }
  8981. declare var WebGLSync: {
  8982. prototype: WebGLSync;
  8983. new (): WebGLSync;
  8984. };
  8985. interface WebGLTransformFeedback extends WebGLObject {
  8986. }
  8987. declare var WebGLTransformFeedback: {
  8988. prototype: WebGLTransformFeedback;
  8989. new (): WebGLTransformFeedback;
  8990. };
  8991. interface WebGLVertexArrayObject extends WebGLObject {
  8992. }
  8993. declare var WebGLVertexArrayObject: {
  8994. prototype: WebGLVertexArrayObject;
  8995. new (): WebGLVertexArrayObject;
  8996. };
  8997. declare module BABYLON {
  8998. class KeyboardEventTypes {
  8999. static _KEYDOWN: number;
  9000. static _KEYUP: number;
  9001. static readonly KEYDOWN: number;
  9002. static readonly KEYUP: number;
  9003. }
  9004. class KeyboardInfo {
  9005. type: number;
  9006. event: KeyboardEvent;
  9007. constructor(type: number, event: KeyboardEvent);
  9008. }
  9009. /**
  9010. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9011. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9012. */
  9013. class KeyboardInfoPre extends KeyboardInfo {
  9014. constructor(type: number, event: KeyboardEvent);
  9015. skipOnPointerObservable: boolean;
  9016. }
  9017. }
  9018. declare module BABYLON {
  9019. class PointerEventTypes {
  9020. static _POINTERDOWN: number;
  9021. static _POINTERUP: number;
  9022. static _POINTERMOVE: number;
  9023. static _POINTERWHEEL: number;
  9024. static _POINTERPICK: number;
  9025. static _POINTERTAP: number;
  9026. static _POINTERDOUBLETAP: number;
  9027. static readonly POINTERDOWN: number;
  9028. static readonly POINTERUP: number;
  9029. static readonly POINTERMOVE: number;
  9030. static readonly POINTERWHEEL: number;
  9031. static readonly POINTERPICK: number;
  9032. static readonly POINTERTAP: number;
  9033. static readonly POINTERDOUBLETAP: number;
  9034. }
  9035. class PointerInfoBase {
  9036. type: number;
  9037. event: PointerEvent | MouseWheelEvent;
  9038. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9039. }
  9040. /**
  9041. * This class is used to store pointer related info for the onPrePointerObservable event.
  9042. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9043. */
  9044. class PointerInfoPre extends PointerInfoBase {
  9045. /**
  9046. * Ray from a pointer if availible (eg. 6dof controller)
  9047. */
  9048. ray: Nullable<Ray>;
  9049. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9050. localPosition: Vector2;
  9051. skipOnPointerObservable: boolean;
  9052. }
  9053. /**
  9054. * This type contains all the data related to a pointer event in Babylon.js.
  9055. * 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.
  9056. */
  9057. class PointerInfo extends PointerInfoBase {
  9058. pickInfo: Nullable<PickingInfo>;
  9059. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9060. }
  9061. }
  9062. declare module BABYLON {
  9063. class StickValues {
  9064. x: number;
  9065. y: number;
  9066. constructor(x: number, y: number);
  9067. }
  9068. interface GamepadButtonChanges {
  9069. changed: boolean;
  9070. pressChanged: boolean;
  9071. touchChanged: boolean;
  9072. valueChanged: boolean;
  9073. }
  9074. class Gamepad {
  9075. id: string;
  9076. index: number;
  9077. browserGamepad: any;
  9078. type: number;
  9079. private _leftStick;
  9080. private _rightStick;
  9081. _isConnected: boolean;
  9082. private _leftStickAxisX;
  9083. private _leftStickAxisY;
  9084. private _rightStickAxisX;
  9085. private _rightStickAxisY;
  9086. private _onleftstickchanged;
  9087. private _onrightstickchanged;
  9088. static GAMEPAD: number;
  9089. static GENERIC: number;
  9090. static XBOX: number;
  9091. static POSE_ENABLED: number;
  9092. protected _invertLeftStickY: boolean;
  9093. readonly isConnected: boolean;
  9094. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9095. onleftstickchanged(callback: (values: StickValues) => void): void;
  9096. onrightstickchanged(callback: (values: StickValues) => void): void;
  9097. leftStick: StickValues;
  9098. rightStick: StickValues;
  9099. update(): void;
  9100. dispose(): void;
  9101. }
  9102. class GenericPad extends Gamepad {
  9103. private _buttons;
  9104. private _onbuttondown;
  9105. private _onbuttonup;
  9106. onButtonDownObservable: Observable<number>;
  9107. onButtonUpObservable: Observable<number>;
  9108. onbuttondown(callback: (buttonPressed: number) => void): void;
  9109. onbuttonup(callback: (buttonReleased: number) => void): void;
  9110. constructor(id: string, index: number, browserGamepad: any);
  9111. private _setButtonValue(newValue, currentValue, buttonIndex);
  9112. update(): void;
  9113. dispose(): void;
  9114. }
  9115. }
  9116. declare module BABYLON {
  9117. class GamepadManager {
  9118. private _scene;
  9119. private _babylonGamepads;
  9120. private _oneGamepadConnected;
  9121. _isMonitoring: boolean;
  9122. private _gamepadEventSupported;
  9123. private _gamepadSupport;
  9124. onGamepadConnectedObservable: Observable<Gamepad>;
  9125. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9126. private _onGamepadConnectedEvent;
  9127. private _onGamepadDisconnectedEvent;
  9128. constructor(_scene?: Scene | undefined);
  9129. readonly gamepads: Gamepad[];
  9130. getGamepadByType(type?: number): Nullable<Gamepad>;
  9131. dispose(): void;
  9132. private _addNewGamepad(gamepad);
  9133. private _startMonitoringGamepads();
  9134. private _stopMonitoringGamepads();
  9135. _checkGamepadsStatus(): void;
  9136. private _updateGamepadObjects();
  9137. }
  9138. }
  9139. declare module BABYLON {
  9140. /**
  9141. * Defines supported buttons for XBox360 compatible gamepads
  9142. */
  9143. enum Xbox360Button {
  9144. /** A */
  9145. A = 0,
  9146. /** B */
  9147. B = 1,
  9148. /** X */
  9149. X = 2,
  9150. /** Y */
  9151. Y = 3,
  9152. /** Start */
  9153. Start = 4,
  9154. /** Back */
  9155. Back = 5,
  9156. /** Left button */
  9157. LB = 6,
  9158. /** Right button */
  9159. RB = 7,
  9160. /** Left stick */
  9161. LeftStick = 8,
  9162. /** Right stick */
  9163. RightStick = 9,
  9164. }
  9165. /** Defines values for XBox360 DPad */
  9166. enum Xbox360Dpad {
  9167. /** Up */
  9168. Up = 0,
  9169. /** Down */
  9170. Down = 1,
  9171. /** Left */
  9172. Left = 2,
  9173. /** Right */
  9174. Right = 3,
  9175. }
  9176. /**
  9177. * Defines a XBox360 gamepad
  9178. */
  9179. class Xbox360Pad extends Gamepad {
  9180. private _leftTrigger;
  9181. private _rightTrigger;
  9182. private _onlefttriggerchanged;
  9183. private _onrighttriggerchanged;
  9184. private _onbuttondown;
  9185. private _onbuttonup;
  9186. private _ondpaddown;
  9187. private _ondpadup;
  9188. /** Observable raised when a button is pressed */
  9189. onButtonDownObservable: Observable<Xbox360Button>;
  9190. /** Observable raised when a button is released */
  9191. onButtonUpObservable: Observable<Xbox360Button>;
  9192. /** Observable raised when a pad is pressed */
  9193. onPadDownObservable: Observable<Xbox360Dpad>;
  9194. /** Observable raised when a pad is released */
  9195. onPadUpObservable: Observable<Xbox360Dpad>;
  9196. private _buttonA;
  9197. private _buttonB;
  9198. private _buttonX;
  9199. private _buttonY;
  9200. private _buttonBack;
  9201. private _buttonStart;
  9202. private _buttonLB;
  9203. private _buttonRB;
  9204. private _buttonLeftStick;
  9205. private _buttonRightStick;
  9206. private _dPadUp;
  9207. private _dPadDown;
  9208. private _dPadLeft;
  9209. private _dPadRight;
  9210. private _isXboxOnePad;
  9211. /**
  9212. * Creates a new XBox360 gamepad object
  9213. * @param id defines the id of this gamepad
  9214. * @param index defines its index
  9215. * @param gamepad defines the internal HTML gamepad object
  9216. * @param xboxOne defines if it is a XBox One gamepad
  9217. */
  9218. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9219. /**
  9220. * Defines the callback to call when left trigger is pressed
  9221. * @param callback defines the callback to use
  9222. */
  9223. onlefttriggerchanged(callback: (value: number) => void): void;
  9224. /**
  9225. * Defines the callback to call when right trigger is pressed
  9226. * @param callback defines the callback to use
  9227. */
  9228. onrighttriggerchanged(callback: (value: number) => void): void;
  9229. /**
  9230. * Gets or sets left trigger value
  9231. */
  9232. leftTrigger: number;
  9233. /**
  9234. * Gets or sets right trigger value
  9235. */
  9236. rightTrigger: number;
  9237. /**
  9238. * Defines the callback to call when a button is pressed
  9239. * @param callback defines the callback to use
  9240. */
  9241. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9242. /**
  9243. * Defines the callback to call when a button is released
  9244. * @param callback defines the callback to use
  9245. */
  9246. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9247. /**
  9248. * Defines the callback to call when a pad is pressed
  9249. * @param callback defines the callback to use
  9250. */
  9251. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9252. /**
  9253. * Defines the callback to call when a pad is released
  9254. * @param callback defines the callback to use
  9255. */
  9256. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9257. private _setButtonValue(newValue, currentValue, buttonType);
  9258. private _setDPadValue(newValue, currentValue, buttonType);
  9259. /** Gets or sets value of A button */
  9260. buttonA: number;
  9261. /** Gets or sets value of B button */
  9262. buttonB: number;
  9263. /** Gets or sets value of X button */
  9264. buttonX: number;
  9265. /** Gets or sets value of Y button */
  9266. buttonY: number;
  9267. /** Gets or sets value of Start button */
  9268. buttonStart: number;
  9269. /** Gets or sets value of Back button */
  9270. buttonBack: number;
  9271. /** Gets or sets value of Left button */
  9272. buttonLB: number;
  9273. /** Gets or sets value of Right button */
  9274. buttonRB: number;
  9275. /** Gets or sets value of left stick */
  9276. buttonLeftStick: number;
  9277. /** Gets or sets value of right stick */
  9278. buttonRightStick: number;
  9279. /** Gets or sets value of DPad up */
  9280. dPadUp: number;
  9281. /** Gets or sets value of DPad down */
  9282. dPadDown: number;
  9283. /** Gets or sets value of DPad left */
  9284. dPadLeft: number;
  9285. /** Gets or sets value of DPad right */
  9286. dPadRight: number;
  9287. /**
  9288. * Force the gamepad to synchronize with device values
  9289. */
  9290. update(): void;
  9291. dispose(): void;
  9292. }
  9293. }
  9294. /**
  9295. * Module Debug contains the (visual) components to debug a scene correctly
  9296. */
  9297. declare module BABYLON.Debug {
  9298. /**
  9299. * The Axes viewer will show 3 axes in a specific point in space
  9300. */
  9301. class AxesViewer {
  9302. private _xline;
  9303. private _yline;
  9304. private _zline;
  9305. private _xmesh;
  9306. private _ymesh;
  9307. private _zmesh;
  9308. /**
  9309. * Gets the hosting scene
  9310. */
  9311. scene: Nullable<Scene>;
  9312. /**
  9313. * Gets or sets a number used to scale line length
  9314. */
  9315. scaleLines: number;
  9316. /**
  9317. * Creates a new AxesViewer
  9318. * @param scene defines the hosting scene
  9319. * @param scaleLines defines a number used to scale line length (1 by default)
  9320. */
  9321. constructor(scene: Scene, scaleLines?: number);
  9322. /**
  9323. * Force the viewer to update
  9324. * @param position defines the position of the viewer
  9325. * @param xaxis defines the x axis of the viewer
  9326. * @param yaxis defines the y axis of the viewer
  9327. * @param zaxis defines the z axis of the viewer
  9328. */
  9329. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9330. /** Releases resources */
  9331. dispose(): void;
  9332. }
  9333. }
  9334. declare module BABYLON.Debug {
  9335. /**
  9336. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9337. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9338. */
  9339. class BoneAxesViewer extends AxesViewer {
  9340. /**
  9341. * Gets or sets the target mesh where to display the axes viewer
  9342. */
  9343. mesh: Nullable<Mesh>;
  9344. /**
  9345. * Gets or sets the target bone where to display the axes viewer
  9346. */
  9347. bone: Nullable<Bone>;
  9348. /** Gets current position */
  9349. pos: Vector3;
  9350. /** Gets direction of X axis */
  9351. xaxis: Vector3;
  9352. /** Gets direction of Y axis */
  9353. yaxis: Vector3;
  9354. /** Gets direction of Z axis */
  9355. zaxis: Vector3;
  9356. /**
  9357. * Creates a new BoneAxesViewer
  9358. * @param scene defines the hosting scene
  9359. * @param bone defines the target bone
  9360. * @param mesh defines the target mesh
  9361. * @param scaleLines defines a scaling factor for line length (1 by default)
  9362. */
  9363. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9364. /**
  9365. * Force the viewer to update
  9366. */
  9367. update(): void;
  9368. /** Releases resources */
  9369. dispose(): void;
  9370. }
  9371. }
  9372. declare module BABYLON {
  9373. class DebugLayer {
  9374. private _scene;
  9375. static InspectorURL: string;
  9376. private _inspector;
  9377. private BJSINSPECTOR;
  9378. constructor(scene: Scene);
  9379. /** Creates the inspector window. */
  9380. private _createInspector(config?);
  9381. isVisible(): boolean;
  9382. hide(): void;
  9383. show(config?: {
  9384. popup?: boolean;
  9385. initialTab?: number;
  9386. parentElement?: HTMLElement;
  9387. newColors?: {
  9388. backgroundColor?: string;
  9389. backgroundColorLighter?: string;
  9390. backgroundColorLighter2?: string;
  9391. backgroundColorLighter3?: string;
  9392. color?: string;
  9393. colorTop?: string;
  9394. colorBot?: string;
  9395. };
  9396. }): void;
  9397. /**
  9398. * Gets the active tab
  9399. * @return the index of the active tab or -1 if the inspector is hidden
  9400. */
  9401. getActiveTab(): number;
  9402. }
  9403. }
  9404. declare module BABYLON.Debug {
  9405. /**
  9406. * Used to show the physics impostor around the specific mesh
  9407. */
  9408. class PhysicsViewer {
  9409. /** @hidden */
  9410. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9411. /** @hidden */
  9412. protected _meshes: Array<Nullable<AbstractMesh>>;
  9413. /** @hidden */
  9414. protected _scene: Nullable<Scene>;
  9415. /** @hidden */
  9416. protected _numMeshes: number;
  9417. /** @hidden */
  9418. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9419. private _renderFunction;
  9420. private _debugBoxMesh;
  9421. private _debugSphereMesh;
  9422. private _debugMaterial;
  9423. /**
  9424. * Creates a new PhysicsViewer
  9425. * @param scene defines the hosting scene
  9426. */
  9427. constructor(scene: Scene);
  9428. /** @hidden */
  9429. protected _updateDebugMeshes(): void;
  9430. /**
  9431. * Renders a specified physic impostor
  9432. * @param impostor defines the impostor to render
  9433. */
  9434. showImpostor(impostor: PhysicsImpostor): void;
  9435. /**
  9436. * Hides a specified physic impostor
  9437. * @param impostor defines the impostor to hide
  9438. */
  9439. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9440. private _getDebugMaterial(scene);
  9441. private _getDebugBoxMesh(scene);
  9442. private _getDebugSphereMesh(scene);
  9443. private _getDebugMesh(impostor, scene);
  9444. /** Releases all resources */
  9445. dispose(): void;
  9446. }
  9447. }
  9448. declare module BABYLON {
  9449. class RayHelper {
  9450. ray: Nullable<Ray>;
  9451. private _renderPoints;
  9452. private _renderLine;
  9453. private _renderFunction;
  9454. private _scene;
  9455. private _updateToMeshFunction;
  9456. private _attachedToMesh;
  9457. private _meshSpaceDirection;
  9458. private _meshSpaceOrigin;
  9459. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9460. constructor(ray: Ray);
  9461. show(scene: Scene, color: Color3): void;
  9462. hide(): void;
  9463. private _render();
  9464. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9465. detachFromMesh(): void;
  9466. private _updateToMesh();
  9467. dispose(): void;
  9468. }
  9469. }
  9470. declare module BABYLON.Debug {
  9471. /**
  9472. * Class used to render a debug view of a given skeleton
  9473. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9474. */
  9475. class SkeletonViewer {
  9476. /** defines the skeleton to render */
  9477. skeleton: Skeleton;
  9478. /** defines the mesh attached to the skeleton */
  9479. mesh: AbstractMesh;
  9480. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9481. autoUpdateBonesMatrices: boolean;
  9482. /** defines the rendering group id to use with the viewer */
  9483. renderingGroupId: number;
  9484. /** Gets or sets the color used to render the skeleton */
  9485. color: Color3;
  9486. private _scene;
  9487. private _debugLines;
  9488. private _debugMesh;
  9489. private _isEnabled;
  9490. private _renderFunction;
  9491. /**
  9492. * Creates a new SkeletonViewer
  9493. * @param skeleton defines the skeleton to render
  9494. * @param mesh defines the mesh attached to the skeleton
  9495. * @param scene defines the hosting scene
  9496. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9497. * @param renderingGroupId defines the rendering group id to use with the viewer
  9498. */
  9499. constructor(
  9500. /** defines the skeleton to render */
  9501. skeleton: Skeleton,
  9502. /** defines the mesh attached to the skeleton */
  9503. mesh: AbstractMesh, scene: Scene,
  9504. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9505. autoUpdateBonesMatrices?: boolean,
  9506. /** defines the rendering group id to use with the viewer */
  9507. renderingGroupId?: number);
  9508. /** Gets or sets a boolean indicating if the viewer is enabled */
  9509. isEnabled: boolean;
  9510. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  9511. private _getLinesForBonesWithLength(bones, meshMat);
  9512. private _getLinesForBonesNoLength(bones, meshMat);
  9513. /** Update the viewer to sync with current skeleton state */
  9514. update(): void;
  9515. /** Release associated resources */
  9516. dispose(): void;
  9517. }
  9518. }
  9519. declare module BABYLON {
  9520. /**
  9521. * Single axis drag gizmo
  9522. */
  9523. class AxisDragGizmo extends Gizmo {
  9524. private _dragBehavior;
  9525. /**
  9526. * Creates an AxisDragGizmo
  9527. * @param gizmoLayer The utility layer the gizmo will be added to
  9528. * @param dragAxis The axis which the gizmo will be able to drag on
  9529. * @param color The color of the gizmo
  9530. */
  9531. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9532. protected _onInteractionsEnabledChanged(value: boolean): void;
  9533. /**
  9534. * Disposes of the gizmo
  9535. */
  9536. dispose(): void;
  9537. }
  9538. }
  9539. declare module BABYLON {
  9540. /**
  9541. * Single axis scale gizmo
  9542. */
  9543. class AxisScaleGizmo extends Gizmo {
  9544. private _dragBehavior;
  9545. /**
  9546. * Creates an AxisScaleGizmo
  9547. * @param gizmoLayer The utility layer the gizmo will be added to
  9548. * @param dragAxis The axis which the gizmo will be able to scale on
  9549. * @param color The color of the gizmo
  9550. */
  9551. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9552. protected _onInteractionsEnabledChanged(value: boolean): void;
  9553. /**
  9554. * Disposes of the gizmo
  9555. */
  9556. dispose(): void;
  9557. }
  9558. }
  9559. declare module BABYLON {
  9560. /**
  9561. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9562. */
  9563. class Gizmo implements IDisposable {
  9564. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9565. /**
  9566. * The root mesh of the gizmo
  9567. */
  9568. protected _rootMesh: Mesh;
  9569. /**
  9570. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9571. */
  9572. attachedMesh: Nullable<AbstractMesh>;
  9573. protected _interactionsEnabled: boolean;
  9574. protected _onInteractionsEnabledChanged(value: boolean): void;
  9575. /**
  9576. * If interactions are enabled with this gizmo. (eg. dragging/rotation)
  9577. */
  9578. interactionsEnabled: boolean;
  9579. private _beforeRenderObserver;
  9580. /**
  9581. * Creates a gizmo
  9582. * @param gizmoLayer The utility layer the gizmo will be added to
  9583. */
  9584. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer);
  9585. /**
  9586. * Disposes of the gizmo
  9587. */
  9588. dispose(): void;
  9589. }
  9590. }
  9591. declare module BABYLON {
  9592. /**
  9593. * Single plane rotation gizmo
  9594. */
  9595. class PlaneRotationGizmo extends Gizmo {
  9596. private _dragBehavior;
  9597. /**
  9598. * Creates a PlaneRotationGizmo
  9599. * @param gizmoLayer The utility layer the gizmo will be added to
  9600. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9601. * @param color The color of the gizmo
  9602. */
  9603. constructor(gizmoLayer: UtilityLayerRenderer, planeNormal: Vector3, color: Color3);
  9604. protected _onInteractionsEnabledChanged(value: boolean): void;
  9605. /**
  9606. * Disposes of the gizmo
  9607. */
  9608. dispose(): void;
  9609. }
  9610. }
  9611. declare module BABYLON {
  9612. /**
  9613. * Gizmo that enables dragging a mesh along 3 axis
  9614. */
  9615. class PositionGizmo extends Gizmo {
  9616. private _xDrag;
  9617. private _yDrag;
  9618. private _zDrag;
  9619. attachedMesh: Nullable<AbstractMesh>;
  9620. /**
  9621. * Creates a PositionGizmo
  9622. * @param gizmoLayer The utility layer the gizmo will be added to
  9623. */
  9624. constructor(gizmoLayer: UtilityLayerRenderer);
  9625. protected _onInteractionsEnabledChanged(value: boolean): void;
  9626. /**
  9627. * Disposes of the gizmo
  9628. */
  9629. dispose(): void;
  9630. }
  9631. }
  9632. declare module BABYLON {
  9633. /**
  9634. * Gizmo that enables rotating a mesh along 3 axis
  9635. */
  9636. class RotationGizmo extends Gizmo {
  9637. private _xDrag;
  9638. private _yDrag;
  9639. private _zDrag;
  9640. attachedMesh: Nullable<AbstractMesh>;
  9641. /**
  9642. * Creates a RotationGizmo
  9643. * @param gizmoLayer The utility layer the gizmo will be added to
  9644. */
  9645. constructor(gizmoLayer: UtilityLayerRenderer);
  9646. protected _onInteractionsEnabledChanged(value: boolean): void;
  9647. /**
  9648. * Disposes of the gizmo
  9649. */
  9650. dispose(): void;
  9651. }
  9652. }
  9653. declare module BABYLON {
  9654. /**
  9655. * Gizmo that enables scaling a mesh along 3 axis
  9656. */
  9657. class ScaleGizmo extends Gizmo {
  9658. private _xDrag;
  9659. private _yDrag;
  9660. private _zDrag;
  9661. attachedMesh: Nullable<AbstractMesh>;
  9662. /**
  9663. * Creates a ScaleGizmo
  9664. * @param gizmoLayer The utility layer the gizmo will be added to
  9665. */
  9666. constructor(gizmoLayer: UtilityLayerRenderer);
  9667. protected _onInteractionsEnabledChanged(value: boolean): void;
  9668. /**
  9669. * Disposes of the gizmo
  9670. */
  9671. dispose(): void;
  9672. }
  9673. }
  9674. declare module BABYLON {
  9675. /**
  9676. * Represents the different options available during the creation of
  9677. * a Environment helper.
  9678. *
  9679. * This can control the default ground, skybox and image processing setup of your scene.
  9680. */
  9681. interface IEnvironmentHelperOptions {
  9682. /**
  9683. * Specifies wether or not to create a ground.
  9684. * True by default.
  9685. */
  9686. createGround: boolean;
  9687. /**
  9688. * Specifies the ground size.
  9689. * 15 by default.
  9690. */
  9691. groundSize: number;
  9692. /**
  9693. * The texture used on the ground for the main color.
  9694. * Comes from the BabylonJS CDN by default.
  9695. *
  9696. * Remarks: Can be either a texture or a url.
  9697. */
  9698. groundTexture: string | BaseTexture;
  9699. /**
  9700. * The color mixed in the ground texture by default.
  9701. * BabylonJS clearColor by default.
  9702. */
  9703. groundColor: Color3;
  9704. /**
  9705. * Specifies the ground opacity.
  9706. * 1 by default.
  9707. */
  9708. groundOpacity: number;
  9709. /**
  9710. * Enables the ground to receive shadows.
  9711. * True by default.
  9712. */
  9713. enableGroundShadow: boolean;
  9714. /**
  9715. * Helps preventing the shadow to be fully black on the ground.
  9716. * 0.5 by default.
  9717. */
  9718. groundShadowLevel: number;
  9719. /**
  9720. * Creates a mirror texture attach to the ground.
  9721. * false by default.
  9722. */
  9723. enableGroundMirror: boolean;
  9724. /**
  9725. * Specifies the ground mirror size ratio.
  9726. * 0.3 by default as the default kernel is 64.
  9727. */
  9728. groundMirrorSizeRatio: number;
  9729. /**
  9730. * Specifies the ground mirror blur kernel size.
  9731. * 64 by default.
  9732. */
  9733. groundMirrorBlurKernel: number;
  9734. /**
  9735. * Specifies the ground mirror visibility amount.
  9736. * 1 by default
  9737. */
  9738. groundMirrorAmount: number;
  9739. /**
  9740. * Specifies the ground mirror reflectance weight.
  9741. * This uses the standard weight of the background material to setup the fresnel effect
  9742. * of the mirror.
  9743. * 1 by default.
  9744. */
  9745. groundMirrorFresnelWeight: number;
  9746. /**
  9747. * Specifies the ground mirror Falloff distance.
  9748. * This can helps reducing the size of the reflection.
  9749. * 0 by Default.
  9750. */
  9751. groundMirrorFallOffDistance: number;
  9752. /**
  9753. * Specifies the ground mirror texture type.
  9754. * Unsigned Int by Default.
  9755. */
  9756. groundMirrorTextureType: number;
  9757. /**
  9758. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9759. * the shown objects.
  9760. */
  9761. groundYBias: number;
  9762. /**
  9763. * Specifies wether or not to create a skybox.
  9764. * True by default.
  9765. */
  9766. createSkybox: boolean;
  9767. /**
  9768. * Specifies the skybox size.
  9769. * 20 by default.
  9770. */
  9771. skyboxSize: number;
  9772. /**
  9773. * The texture used on the skybox for the main color.
  9774. * Comes from the BabylonJS CDN by default.
  9775. *
  9776. * Remarks: Can be either a texture or a url.
  9777. */
  9778. skyboxTexture: string | BaseTexture;
  9779. /**
  9780. * The color mixed in the skybox texture by default.
  9781. * BabylonJS clearColor by default.
  9782. */
  9783. skyboxColor: Color3;
  9784. /**
  9785. * The background rotation around the Y axis of the scene.
  9786. * This helps aligning the key lights of your scene with the background.
  9787. * 0 by default.
  9788. */
  9789. backgroundYRotation: number;
  9790. /**
  9791. * Compute automatically the size of the elements to best fit with the scene.
  9792. */
  9793. sizeAuto: boolean;
  9794. /**
  9795. * Default position of the rootMesh if autoSize is not true.
  9796. */
  9797. rootPosition: Vector3;
  9798. /**
  9799. * Sets up the image processing in the scene.
  9800. * true by default.
  9801. */
  9802. setupImageProcessing: boolean;
  9803. /**
  9804. * The texture used as your environment texture in the scene.
  9805. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9806. *
  9807. * Remarks: Can be either a texture or a url.
  9808. */
  9809. environmentTexture: string | BaseTexture;
  9810. /**
  9811. * The value of the exposure to apply to the scene.
  9812. * 0.6 by default if setupImageProcessing is true.
  9813. */
  9814. cameraExposure: number;
  9815. /**
  9816. * The value of the contrast to apply to the scene.
  9817. * 1.6 by default if setupImageProcessing is true.
  9818. */
  9819. cameraContrast: number;
  9820. /**
  9821. * Specifies wether or not tonemapping should be enabled in the scene.
  9822. * true by default if setupImageProcessing is true.
  9823. */
  9824. toneMappingEnabled: boolean;
  9825. }
  9826. /**
  9827. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9828. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9829. * It also helps with the default setup of your imageProcessing configuration.
  9830. */
  9831. class EnvironmentHelper {
  9832. /**
  9833. * Default ground texture URL.
  9834. */
  9835. private static _groundTextureCDNUrl;
  9836. /**
  9837. * Default skybox texture URL.
  9838. */
  9839. private static _skyboxTextureCDNUrl;
  9840. /**
  9841. * Default environment texture URL.
  9842. */
  9843. private static _environmentTextureCDNUrl;
  9844. /**
  9845. * Creates the default options for the helper.
  9846. */
  9847. private static _getDefaultOptions();
  9848. private _rootMesh;
  9849. /**
  9850. * Gets the root mesh created by the helper.
  9851. */
  9852. readonly rootMesh: Mesh;
  9853. private _skybox;
  9854. /**
  9855. * Gets the skybox created by the helper.
  9856. */
  9857. readonly skybox: Nullable<Mesh>;
  9858. private _skyboxTexture;
  9859. /**
  9860. * Gets the skybox texture created by the helper.
  9861. */
  9862. readonly skyboxTexture: Nullable<BaseTexture>;
  9863. private _skyboxMaterial;
  9864. /**
  9865. * Gets the skybox material created by the helper.
  9866. */
  9867. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9868. private _ground;
  9869. /**
  9870. * Gets the ground mesh created by the helper.
  9871. */
  9872. readonly ground: Nullable<Mesh>;
  9873. private _groundTexture;
  9874. /**
  9875. * Gets the ground texture created by the helper.
  9876. */
  9877. readonly groundTexture: Nullable<BaseTexture>;
  9878. private _groundMirror;
  9879. /**
  9880. * Gets the ground mirror created by the helper.
  9881. */
  9882. readonly groundMirror: Nullable<MirrorTexture>;
  9883. /**
  9884. * Gets the ground mirror render list to helps pushing the meshes
  9885. * you wish in the ground reflection.
  9886. */
  9887. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9888. private _groundMaterial;
  9889. /**
  9890. * Gets the ground material created by the helper.
  9891. */
  9892. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9893. /**
  9894. * Stores the creation options.
  9895. */
  9896. private readonly _scene;
  9897. private _options;
  9898. /**
  9899. * This observable will be notified with any error during the creation of the environment,
  9900. * mainly texture creation errors.
  9901. */
  9902. onErrorObservable: Observable<{
  9903. message?: string;
  9904. exception?: any;
  9905. }>;
  9906. /**
  9907. * constructor
  9908. * @param options
  9909. * @param scene The scene to add the material to
  9910. */
  9911. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9912. /**
  9913. * Updates the background according to the new options
  9914. * @param options
  9915. */
  9916. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9917. /**
  9918. * Sets the primary color of all the available elements.
  9919. * @param color the main color to affect to the ground and the background
  9920. */
  9921. setMainColor(color: Color3): void;
  9922. /**
  9923. * Setup the image processing according to the specified options.
  9924. */
  9925. private _setupImageProcessing();
  9926. /**
  9927. * Setup the environment texture according to the specified options.
  9928. */
  9929. private _setupEnvironmentTexture();
  9930. /**
  9931. * Setup the background according to the specified options.
  9932. */
  9933. private _setupBackground();
  9934. /**
  9935. * Get the scene sizes according to the setup.
  9936. */
  9937. private _getSceneSize();
  9938. /**
  9939. * Setup the ground according to the specified options.
  9940. */
  9941. private _setupGround(sceneSize);
  9942. /**
  9943. * Setup the ground material according to the specified options.
  9944. */
  9945. private _setupGroundMaterial();
  9946. /**
  9947. * Setup the ground diffuse texture according to the specified options.
  9948. */
  9949. private _setupGroundDiffuseTexture();
  9950. /**
  9951. * Setup the ground mirror texture according to the specified options.
  9952. */
  9953. private _setupGroundMirrorTexture(sceneSize);
  9954. /**
  9955. * Setup the ground to receive the mirror texture.
  9956. */
  9957. private _setupMirrorInGroundMaterial();
  9958. /**
  9959. * Setup the skybox according to the specified options.
  9960. */
  9961. private _setupSkybox(sceneSize);
  9962. /**
  9963. * Setup the skybox material according to the specified options.
  9964. */
  9965. private _setupSkyboxMaterial();
  9966. /**
  9967. * Setup the skybox reflection texture according to the specified options.
  9968. */
  9969. private _setupSkyboxReflectionTexture();
  9970. private _errorHandler;
  9971. /**
  9972. * Dispose all the elements created by the Helper.
  9973. */
  9974. dispose(): void;
  9975. }
  9976. }
  9977. declare module BABYLON {
  9978. /**
  9979. * Represents all the data needed to create a ParticleSystem.
  9980. */
  9981. interface IParticleSystemData {
  9982. /**
  9983. * ParticleSystem type
  9984. */
  9985. type: string;
  9986. /**
  9987. * Shape of the emitter
  9988. */
  9989. emitterType: string;
  9990. /**
  9991. * Maximum number of particles in the system
  9992. */
  9993. capacity: number;
  9994. /**
  9995. * Link for the texture file
  9996. */
  9997. textureFile: string;
  9998. /**
  9999. * minEmitBox Vector3
  10000. */
  10001. minEmitBox?: {
  10002. x: number;
  10003. y: number;
  10004. z: number;
  10005. };
  10006. /**
  10007. * maxEmitBox Vector3
  10008. */
  10009. maxEmitBox?: {
  10010. x: number;
  10011. y: number;
  10012. z: number;
  10013. };
  10014. /**
  10015. * color1 Color4
  10016. */
  10017. color1: {
  10018. r: number;
  10019. g: number;
  10020. b: number;
  10021. a: number;
  10022. };
  10023. /**
  10024. * color2 Color4
  10025. */
  10026. color2: {
  10027. r: number;
  10028. g: number;
  10029. b: number;
  10030. a: number;
  10031. };
  10032. /**
  10033. * colorDead Color4
  10034. */
  10035. colorDead: {
  10036. r: number;
  10037. g: number;
  10038. b: number;
  10039. a: number;
  10040. };
  10041. /**
  10042. * Minimum size of each particle
  10043. */
  10044. minSize: number;
  10045. /**
  10046. * Maximum size of each particle
  10047. */
  10048. maxSize: number;
  10049. /**
  10050. * Minimum lifetime for each particle
  10051. */
  10052. minLifeTime: number;
  10053. /**
  10054. * Maximum lifetime for each particle
  10055. */
  10056. maxLifeTime: number;
  10057. /**
  10058. * Emit rate
  10059. */
  10060. emitRate: number;
  10061. /**
  10062. * Blend Mode
  10063. */
  10064. blendMode: number;
  10065. /**
  10066. * gravity Vector3
  10067. */
  10068. gravity: {
  10069. x: number;
  10070. y: number;
  10071. z: number;
  10072. };
  10073. /**
  10074. * direction1 Vector3
  10075. */
  10076. direction1?: {
  10077. x: number;
  10078. y: number;
  10079. z: number;
  10080. };
  10081. /**
  10082. * direction2 Vector3
  10083. */
  10084. direction2?: {
  10085. x: number;
  10086. y: number;
  10087. z: number;
  10088. };
  10089. /**
  10090. * Minimum Angular Speed
  10091. */
  10092. minAngularSpeed: number;
  10093. /**
  10094. * Maximum Angular Speed
  10095. */
  10096. maxAngularSpeed: number;
  10097. /**
  10098. * Minimum Emit Power
  10099. */
  10100. minEmitPower: number;
  10101. /**
  10102. * Maximum Emit Power
  10103. */
  10104. maxEmitPower: number;
  10105. /**
  10106. * Update Speed
  10107. */
  10108. updateSpeed: number;
  10109. /**
  10110. * Radius
  10111. */
  10112. radius?: number;
  10113. /**
  10114. * Angle
  10115. */
  10116. angle?: number;
  10117. }
  10118. /**
  10119. * This class is made for on one-liner static method to help creating particle systems.
  10120. */
  10121. class ParticleHelper {
  10122. /**
  10123. * Base Assets URL.
  10124. */
  10125. private static _baseAssetsUrl;
  10126. private static _scene;
  10127. private static _emitter;
  10128. /**
  10129. * This is the main static method (one-liner) of this helper to create different particle systems.
  10130. * @param type This string represents the type to the particle system to create
  10131. * @param emitter The object where the particle system will start to emit from.
  10132. * @param scene The scene where the particle system should live.
  10133. * @param gpu If the system will use gpu.
  10134. * @returns the ParticleSystem created.
  10135. */
  10136. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  10137. private static _createSystem(data);
  10138. }
  10139. }
  10140. declare module BABYLON {
  10141. /**
  10142. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10143. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10144. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10145. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10146. */
  10147. class VideoDome extends Node {
  10148. /**
  10149. * The video texture being displayed on the sphere
  10150. */
  10151. protected _videoTexture: VideoTexture;
  10152. /**
  10153. * The skybox material
  10154. */
  10155. protected _material: BackgroundMaterial;
  10156. /**
  10157. * The surface used for the skybox
  10158. */
  10159. protected _mesh: Mesh;
  10160. /**
  10161. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10162. * Also see the options.resolution property.
  10163. */
  10164. fovMultiplier: number;
  10165. /**
  10166. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10167. * @param name Element's name, child elements will append suffixes for their own names.
  10168. * @param urlsOrVideo
  10169. * @param options An object containing optional or exposed sub element properties:
  10170. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  10171. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  10172. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  10173. * @param options **loop=true** Automatically loop video on end.
  10174. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  10175. */
  10176. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10177. resolution?: number;
  10178. clickToPlay?: boolean;
  10179. autoPlay?: boolean;
  10180. loop?: boolean;
  10181. size?: number;
  10182. }, scene: Scene);
  10183. /**
  10184. * Releases resources associated with this node.
  10185. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10186. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10187. */
  10188. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10189. }
  10190. }
  10191. declare module BABYLON {
  10192. class LensFlare {
  10193. size: number;
  10194. position: number;
  10195. color: Color3;
  10196. texture: Nullable<Texture>;
  10197. alphaMode: number;
  10198. private _system;
  10199. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10200. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10201. dispose(): void;
  10202. }
  10203. }
  10204. declare module BABYLON {
  10205. class LensFlareSystem {
  10206. name: string;
  10207. lensFlares: LensFlare[];
  10208. borderLimit: number;
  10209. viewportBorder: number;
  10210. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10211. layerMask: number;
  10212. id: string;
  10213. private _scene;
  10214. private _emitter;
  10215. private _vertexBuffers;
  10216. private _indexBuffer;
  10217. private _effect;
  10218. private _positionX;
  10219. private _positionY;
  10220. private _isEnabled;
  10221. constructor(name: string, emitter: any, scene: Scene);
  10222. isEnabled: boolean;
  10223. getScene(): Scene;
  10224. getEmitter(): any;
  10225. setEmitter(newEmitter: any): void;
  10226. getEmitterPosition(): Vector3;
  10227. computeEffectivePosition(globalViewport: Viewport): boolean;
  10228. _isVisible(): boolean;
  10229. render(): boolean;
  10230. dispose(): void;
  10231. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10232. serialize(): any;
  10233. }
  10234. }
  10235. declare module BABYLON {
  10236. /**
  10237. * This class can be used to get instrumentation data from a Babylon engine
  10238. */
  10239. class EngineInstrumentation implements IDisposable {
  10240. engine: Engine;
  10241. private _captureGPUFrameTime;
  10242. private _gpuFrameTimeToken;
  10243. private _gpuFrameTime;
  10244. private _captureShaderCompilationTime;
  10245. private _shaderCompilationTime;
  10246. private _onBeginFrameObserver;
  10247. private _onEndFrameObserver;
  10248. private _onBeforeShaderCompilationObserver;
  10249. private _onAfterShaderCompilationObserver;
  10250. /**
  10251. * Gets the perf counter used for GPU frame time
  10252. */
  10253. readonly gpuFrameTimeCounter: PerfCounter;
  10254. /**
  10255. * Gets the GPU frame time capture status
  10256. */
  10257. /**
  10258. * Enable or disable the GPU frame time capture
  10259. */
  10260. captureGPUFrameTime: boolean;
  10261. /**
  10262. * Gets the perf counter used for shader compilation time
  10263. */
  10264. readonly shaderCompilationTimeCounter: PerfCounter;
  10265. /**
  10266. * Gets the shader compilation time capture status
  10267. */
  10268. /**
  10269. * Enable or disable the shader compilation time capture
  10270. */
  10271. captureShaderCompilationTime: boolean;
  10272. constructor(engine: Engine);
  10273. dispose(): void;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * This class can be used to get instrumentation data from a Babylon engine
  10279. */
  10280. class SceneInstrumentation implements IDisposable {
  10281. scene: Scene;
  10282. private _captureActiveMeshesEvaluationTime;
  10283. private _activeMeshesEvaluationTime;
  10284. private _captureRenderTargetsRenderTime;
  10285. private _renderTargetsRenderTime;
  10286. private _captureFrameTime;
  10287. private _frameTime;
  10288. private _captureRenderTime;
  10289. private _renderTime;
  10290. private _captureInterFrameTime;
  10291. private _interFrameTime;
  10292. private _captureParticlesRenderTime;
  10293. private _particlesRenderTime;
  10294. private _captureSpritesRenderTime;
  10295. private _spritesRenderTime;
  10296. private _capturePhysicsTime;
  10297. private _physicsTime;
  10298. private _captureAnimationsTime;
  10299. private _animationsTime;
  10300. private _onBeforeActiveMeshesEvaluationObserver;
  10301. private _onAfterActiveMeshesEvaluationObserver;
  10302. private _onBeforeRenderTargetsRenderObserver;
  10303. private _onAfterRenderTargetsRenderObserver;
  10304. private _onAfterRenderObserver;
  10305. private _onBeforeDrawPhaseObserver;
  10306. private _onAfterDrawPhaseObserver;
  10307. private _onBeforeAnimationsObserver;
  10308. private _onBeforeParticlesRenderingObserver;
  10309. private _onAfterParticlesRenderingObserver;
  10310. private _onBeforeSpritesRenderingObserver;
  10311. private _onAfterSpritesRenderingObserver;
  10312. private _onBeforePhysicsObserver;
  10313. private _onAfterPhysicsObserver;
  10314. private _onAfterAnimationsObserver;
  10315. /**
  10316. * Gets the perf counter used for active meshes evaluation time
  10317. */
  10318. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10319. /**
  10320. * Gets the active meshes evaluation time capture status
  10321. */
  10322. /**
  10323. * Enable or disable the active meshes evaluation time capture
  10324. */
  10325. captureActiveMeshesEvaluationTime: boolean;
  10326. /**
  10327. * Gets the perf counter used for render targets render time
  10328. */
  10329. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10330. /**
  10331. * Gets the render targets render time capture status
  10332. */
  10333. /**
  10334. * Enable or disable the render targets render time capture
  10335. */
  10336. captureRenderTargetsRenderTime: boolean;
  10337. /**
  10338. * Gets the perf counter used for particles render time
  10339. */
  10340. readonly particlesRenderTimeCounter: PerfCounter;
  10341. /**
  10342. * Gets the particles render time capture status
  10343. */
  10344. /**
  10345. * Enable or disable the particles render time capture
  10346. */
  10347. captureParticlesRenderTime: boolean;
  10348. /**
  10349. * Gets the perf counter used for sprites render time
  10350. */
  10351. readonly spritesRenderTimeCounter: PerfCounter;
  10352. /**
  10353. * Gets the sprites render time capture status
  10354. */
  10355. /**
  10356. * Enable or disable the sprites render time capture
  10357. */
  10358. captureSpritesRenderTime: boolean;
  10359. /**
  10360. * Gets the perf counter used for physics time
  10361. */
  10362. readonly physicsTimeCounter: PerfCounter;
  10363. /**
  10364. * Gets the physics time capture status
  10365. */
  10366. /**
  10367. * Enable or disable the physics time capture
  10368. */
  10369. capturePhysicsTime: boolean;
  10370. /**
  10371. * Gets the perf counter used for animations time
  10372. */
  10373. readonly animationsTimeCounter: PerfCounter;
  10374. /**
  10375. * Gets the animations time capture status
  10376. */
  10377. /**
  10378. * Enable or disable the animations time capture
  10379. */
  10380. captureAnimationsTime: boolean;
  10381. /**
  10382. * Gets the perf counter used for frame time capture
  10383. */
  10384. readonly frameTimeCounter: PerfCounter;
  10385. /**
  10386. * Gets the frame time capture status
  10387. */
  10388. /**
  10389. * Enable or disable the frame time capture
  10390. */
  10391. captureFrameTime: boolean;
  10392. /**
  10393. * Gets the perf counter used for inter-frames time capture
  10394. */
  10395. readonly interFrameTimeCounter: PerfCounter;
  10396. /**
  10397. * Gets the inter-frames time capture status
  10398. */
  10399. /**
  10400. * Enable or disable the inter-frames time capture
  10401. */
  10402. captureInterFrameTime: boolean;
  10403. /**
  10404. * Gets the perf counter used for render time capture
  10405. */
  10406. readonly renderTimeCounter: PerfCounter;
  10407. /**
  10408. * Gets the render time capture status
  10409. */
  10410. /**
  10411. * Enable or disable the render time capture
  10412. */
  10413. captureRenderTime: boolean;
  10414. /**
  10415. * Gets the perf counter used for draw calls
  10416. */
  10417. readonly drawCallsCounter: PerfCounter;
  10418. /**
  10419. * Gets the perf counter used for texture collisions
  10420. */
  10421. readonly textureCollisionsCounter: PerfCounter;
  10422. constructor(scene: Scene);
  10423. dispose(): void;
  10424. }
  10425. }
  10426. declare module BABYLON {
  10427. /**
  10428. * @hidden
  10429. **/
  10430. class _TimeToken {
  10431. _startTimeQuery: Nullable<WebGLQuery>;
  10432. _endTimeQuery: Nullable<WebGLQuery>;
  10433. _timeElapsedQuery: Nullable<WebGLQuery>;
  10434. _timeElapsedQueryEnded: boolean;
  10435. }
  10436. }
  10437. declare module BABYLON {
  10438. /**
  10439. * A directional light is defined by a direction (what a surprise!).
  10440. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10441. * 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.
  10442. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10443. */
  10444. class DirectionalLight extends ShadowLight {
  10445. private _shadowFrustumSize;
  10446. /**
  10447. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10448. */
  10449. /**
  10450. * Specifies a fix frustum size for the shadow generation.
  10451. */
  10452. shadowFrustumSize: number;
  10453. private _shadowOrthoScale;
  10454. /**
  10455. * Gets the shadow projection scale against the optimal computed one.
  10456. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10457. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10458. */
  10459. /**
  10460. * Sets the shadow projection scale against the optimal computed one.
  10461. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10462. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10463. */
  10464. shadowOrthoScale: number;
  10465. /**
  10466. * Automatically compute the projection matrix to best fit (including all the casters)
  10467. * on each frame.
  10468. */
  10469. autoUpdateExtends: boolean;
  10470. private _orthoLeft;
  10471. private _orthoRight;
  10472. private _orthoTop;
  10473. private _orthoBottom;
  10474. /**
  10475. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10476. * The directional light is emitted from everywhere in the given direction.
  10477. * It can cast shawdows.
  10478. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10479. * @param name The friendly name of the light
  10480. * @param direction The direction of the light
  10481. * @param scene The scene the light belongs to
  10482. */
  10483. constructor(name: string, direction: Vector3, scene: Scene);
  10484. /**
  10485. * Returns the string "DirectionalLight".
  10486. * @return The class name
  10487. */
  10488. getClassName(): string;
  10489. /**
  10490. * Returns the integer 1.
  10491. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10492. */
  10493. getTypeID(): number;
  10494. /**
  10495. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10496. * Returns the DirectionalLight Shadow projection matrix.
  10497. */
  10498. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10499. /**
  10500. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  10501. * Returns the DirectionalLight Shadow projection matrix.
  10502. */
  10503. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  10504. /**
  10505. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10506. * Returns the DirectionalLight Shadow projection matrix.
  10507. */
  10508. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10509. protected _buildUniformLayout(): void;
  10510. /**
  10511. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  10512. * @param effect The effect to update
  10513. * @param lightIndex The index of the light in the effect to update
  10514. * @returns The directional light
  10515. */
  10516. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  10517. /**
  10518. * Gets the minZ used for shadow according to both the scene and the light.
  10519. *
  10520. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10521. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10522. * @param activeCamera The camera we are returning the min for
  10523. * @returns the depth min z
  10524. */
  10525. getDepthMinZ(activeCamera: Camera): number;
  10526. /**
  10527. * Gets the maxZ used for shadow according to both the scene and the light.
  10528. *
  10529. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10530. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10531. * @param activeCamera The camera we are returning the max for
  10532. * @returns the depth max z
  10533. */
  10534. getDepthMaxZ(activeCamera: Camera): number;
  10535. }
  10536. }
  10537. declare module BABYLON {
  10538. /**
  10539. * The HemisphericLight simulates the ambient environment light,
  10540. * so the passed direction is the light reflection direction, not the incoming direction.
  10541. */
  10542. class HemisphericLight extends Light {
  10543. /**
  10544. * The groundColor is the light in the opposite direction to the one specified during creation.
  10545. * 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.
  10546. */
  10547. groundColor: Color3;
  10548. /**
  10549. * The light reflection direction, not the incoming direction.
  10550. */
  10551. direction: Vector3;
  10552. private _worldMatrix;
  10553. /**
  10554. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10555. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10556. * The HemisphericLight can't cast shadows.
  10557. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10558. * @param name The friendly name of the light
  10559. * @param direction The direction of the light reflection
  10560. * @param scene The scene the light belongs to
  10561. */
  10562. constructor(name: string, direction: Vector3, scene: Scene);
  10563. protected _buildUniformLayout(): void;
  10564. /**
  10565. * Returns the string "HemisphericLight".
  10566. * @return The class name
  10567. */
  10568. getClassName(): string;
  10569. /**
  10570. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10571. * Returns the updated direction.
  10572. * @param target The target the direction should point to
  10573. * @return The computed direction
  10574. */
  10575. setDirectionToTarget(target: Vector3): Vector3;
  10576. /**
  10577. * Returns the shadow generator associated to the light.
  10578. * @returns Always null for hemispheric lights because it does not support shadows.
  10579. */
  10580. getShadowGenerator(): Nullable<ShadowGenerator>;
  10581. /**
  10582. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10583. * @param effect The effect to update
  10584. * @param lightIndex The index of the light in the effect to update
  10585. * @returns The hemispheric light
  10586. */
  10587. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10588. /**
  10589. * @hidden internal use only.
  10590. */
  10591. _getWorldMatrix(): Matrix;
  10592. /**
  10593. * Returns the integer 3.
  10594. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10595. */
  10596. getTypeID(): number;
  10597. }
  10598. }
  10599. declare module BABYLON {
  10600. /**
  10601. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10602. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10603. * 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.
  10604. */
  10605. abstract class Light extends Node {
  10606. private static _LIGHTMAP_DEFAULT;
  10607. private static _LIGHTMAP_SPECULAR;
  10608. private static _LIGHTMAP_SHADOWSONLY;
  10609. /**
  10610. * If every light affecting the material is in this lightmapMode,
  10611. * material.lightmapTexture adds or multiplies
  10612. * (depends on material.useLightmapAsShadowmap)
  10613. * after every other light calculations.
  10614. */
  10615. static readonly LIGHTMAP_DEFAULT: number;
  10616. /**
  10617. * material.lightmapTexture as only diffuse lighting from this light
  10618. * adds only specular lighting from this light
  10619. * adds dynamic shadows
  10620. */
  10621. static readonly LIGHTMAP_SPECULAR: number;
  10622. /**
  10623. * material.lightmapTexture as only lighting
  10624. * no light calculation from this light
  10625. * only adds dynamic shadows from this light
  10626. */
  10627. static readonly LIGHTMAP_SHADOWSONLY: number;
  10628. private static _INTENSITYMODE_AUTOMATIC;
  10629. private static _INTENSITYMODE_LUMINOUSPOWER;
  10630. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  10631. private static _INTENSITYMODE_ILLUMINANCE;
  10632. private static _INTENSITYMODE_LUMINANCE;
  10633. /**
  10634. * Each light type uses the default quantity according to its type:
  10635. * point/spot lights use luminous intensity
  10636. * directional lights use illuminance
  10637. */
  10638. static readonly INTENSITYMODE_AUTOMATIC: number;
  10639. /**
  10640. * lumen (lm)
  10641. */
  10642. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10643. /**
  10644. * candela (lm/sr)
  10645. */
  10646. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10647. /**
  10648. * lux (lm/m^2)
  10649. */
  10650. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10651. /**
  10652. * nit (cd/m^2)
  10653. */
  10654. static readonly INTENSITYMODE_LUMINANCE: number;
  10655. private static _LIGHTTYPEID_POINTLIGHT;
  10656. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  10657. private static _LIGHTTYPEID_SPOTLIGHT;
  10658. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  10659. /**
  10660. * Light type const id of the point light.
  10661. */
  10662. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10663. /**
  10664. * Light type const id of the directional light.
  10665. */
  10666. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10667. /**
  10668. * Light type const id of the spot light.
  10669. */
  10670. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10671. /**
  10672. * Light type const id of the hemispheric light.
  10673. */
  10674. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10675. /**
  10676. * Diffuse gives the basic color to an object.
  10677. */
  10678. diffuse: Color3;
  10679. /**
  10680. * Specular produces a highlight color on an object.
  10681. * Note: This is note affecting PBR materials.
  10682. */
  10683. specular: Color3;
  10684. /**
  10685. * Strength of the light.
  10686. * Note: By default it is define in the framework own unit.
  10687. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10688. */
  10689. intensity: number;
  10690. /**
  10691. * Defines how far from the source the light is impacting in scene units.
  10692. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10693. */
  10694. range: number;
  10695. /**
  10696. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10697. * of light.
  10698. */
  10699. private _photometricScale;
  10700. private _intensityMode;
  10701. /**
  10702. * Gets the photometric scale used to interpret the intensity.
  10703. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10704. */
  10705. /**
  10706. * Sets the photometric scale used to interpret the intensity.
  10707. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10708. */
  10709. intensityMode: number;
  10710. private _radius;
  10711. /**
  10712. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10713. */
  10714. /**
  10715. * sets the light radius used by PBR Materials to simulate soft area lights.
  10716. */
  10717. radius: number;
  10718. private _renderPriority;
  10719. /**
  10720. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10721. * exceeding the number allowed of the materials.
  10722. */
  10723. renderPriority: number;
  10724. private _shadowEnabled;
  10725. /**
  10726. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10727. * the current shadow generator.
  10728. */
  10729. /**
  10730. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10731. * the current shadow generator.
  10732. */
  10733. shadowEnabled: boolean;
  10734. private _includedOnlyMeshes;
  10735. /**
  10736. * Gets the only meshes impacted by this light.
  10737. */
  10738. /**
  10739. * Sets the only meshes impacted by this light.
  10740. */
  10741. includedOnlyMeshes: AbstractMesh[];
  10742. private _excludedMeshes;
  10743. /**
  10744. * Gets the meshes not impacted by this light.
  10745. */
  10746. /**
  10747. * Sets the meshes not impacted by this light.
  10748. */
  10749. excludedMeshes: AbstractMesh[];
  10750. private _excludeWithLayerMask;
  10751. /**
  10752. * Gets the layer id use to find what meshes are not impacted by the light.
  10753. * Inactive if 0
  10754. */
  10755. /**
  10756. * Sets the layer id use to find what meshes are not impacted by the light.
  10757. * Inactive if 0
  10758. */
  10759. excludeWithLayerMask: number;
  10760. private _includeOnlyWithLayerMask;
  10761. /**
  10762. * Gets the layer id use to find what meshes are impacted by the light.
  10763. * Inactive if 0
  10764. */
  10765. /**
  10766. * Sets the layer id use to find what meshes are impacted by the light.
  10767. * Inactive if 0
  10768. */
  10769. includeOnlyWithLayerMask: number;
  10770. private _lightmapMode;
  10771. /**
  10772. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10773. */
  10774. /**
  10775. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10776. */
  10777. lightmapMode: number;
  10778. private _parentedWorldMatrix;
  10779. /**
  10780. * Shadow generator associted to the light.
  10781. * Internal use only.
  10782. */
  10783. _shadowGenerator: Nullable<IShadowGenerator>;
  10784. /**
  10785. * @hidden Internal use only.
  10786. */
  10787. _excludedMeshesIds: string[];
  10788. /**
  10789. * @hidden Internal use only.
  10790. */
  10791. _includedOnlyMeshesIds: string[];
  10792. /**
  10793. * The current light unifom buffer.
  10794. * @hidden Internal use only.
  10795. */
  10796. _uniformBuffer: UniformBuffer;
  10797. /**
  10798. * Creates a Light object in the scene.
  10799. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10800. * @param name The firendly name of the light
  10801. * @param scene The scene the light belongs too
  10802. */
  10803. constructor(name: string, scene: Scene);
  10804. protected abstract _buildUniformLayout(): void;
  10805. /**
  10806. * Sets the passed Effect "effect" with the Light information.
  10807. * @param effect The effect to update
  10808. * @param lightIndex The index of the light in the effect to update
  10809. * @returns The light
  10810. */
  10811. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10812. /**
  10813. * @hidden internal use only.
  10814. */
  10815. abstract _getWorldMatrix(): Matrix;
  10816. /**
  10817. * Returns the string "Light".
  10818. * @returns the class name
  10819. */
  10820. getClassName(): string;
  10821. /**
  10822. * Converts the light information to a readable string for debug purpose.
  10823. * @param fullDetails Supports for multiple levels of logging within scene loading
  10824. * @returns the human readable light info
  10825. */
  10826. toString(fullDetails?: boolean): string;
  10827. /**
  10828. * Set the enabled state of this node.
  10829. * @param value - the new enabled state
  10830. */
  10831. setEnabled(value: boolean): void;
  10832. /**
  10833. * Returns the Light associated shadow generator if any.
  10834. * @return the associated shadow generator.
  10835. */
  10836. getShadowGenerator(): Nullable<IShadowGenerator>;
  10837. /**
  10838. * Returns a Vector3, the absolute light position in the World.
  10839. * @returns the world space position of the light
  10840. */
  10841. getAbsolutePosition(): Vector3;
  10842. /**
  10843. * Specifies if the light will affect the passed mesh.
  10844. * @param mesh The mesh to test against the light
  10845. * @return true the mesh is affected otherwise, false.
  10846. */
  10847. canAffectMesh(mesh: AbstractMesh): boolean;
  10848. /**
  10849. * Computes and Returns the light World matrix.
  10850. * @returns the world matrix
  10851. */
  10852. getWorldMatrix(): Matrix;
  10853. /**
  10854. * Sort function to order lights for rendering.
  10855. * @param a First Light object to compare to second.
  10856. * @param b Second Light object to compare first.
  10857. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10858. */
  10859. static CompareLightsPriority(a: Light, b: Light): number;
  10860. /**
  10861. * Releases resources associated with this node.
  10862. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10863. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10864. */
  10865. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10866. /**
  10867. * Returns the light type ID (integer).
  10868. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10869. */
  10870. getTypeID(): number;
  10871. /**
  10872. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10873. * @returns the scaled intensity in intensity mode unit
  10874. */
  10875. getScaledIntensity(): number;
  10876. /**
  10877. * Returns a new Light object, named "name", from the current one.
  10878. * @param name The name of the cloned light
  10879. * @returns the new created light
  10880. */
  10881. clone(name: string): Nullable<Light>;
  10882. /**
  10883. * Serializes the current light into a Serialization object.
  10884. * @returns the serialized object.
  10885. */
  10886. serialize(): any;
  10887. /**
  10888. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10889. * This new light is named "name" and added to the passed scene.
  10890. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10891. * @param name The friendly name of the light
  10892. * @param scene The scene the new light will belong to
  10893. * @returns the constructor function
  10894. */
  10895. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10896. /**
  10897. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10898. * @param parsedLight The JSON representation of the light
  10899. * @param scene The scene to create the parsed light in
  10900. * @returns the created light after parsing
  10901. */
  10902. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10903. private _hookArrayForExcluded(array);
  10904. private _hookArrayForIncludedOnly(array);
  10905. private _resyncMeshes();
  10906. /**
  10907. * Forces the meshes to update their light related information in their rendering used effects
  10908. * @hidden Internal Use Only
  10909. */
  10910. _markMeshesAsLightDirty(): void;
  10911. /**
  10912. * Recomputes the cached photometric scale if needed.
  10913. */
  10914. private _computePhotometricScale();
  10915. /**
  10916. * Returns the Photometric Scale according to the light type and intensity mode.
  10917. */
  10918. private _getPhotometricScale();
  10919. /**
  10920. * Reorder the light in the scene according to their defined priority.
  10921. * @hidden Internal Use Only
  10922. */
  10923. _reorderLightsInScene(): void;
  10924. }
  10925. }
  10926. declare module BABYLON {
  10927. /**
  10928. * A point light is a light defined by an unique point in world space.
  10929. * The light is emitted in every direction from this point.
  10930. * A good example of a point light is a standard light bulb.
  10931. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10932. */
  10933. class PointLight extends ShadowLight {
  10934. private _shadowAngle;
  10935. /**
  10936. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10937. * This specifies what angle the shadow will use to be created.
  10938. *
  10939. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10940. */
  10941. /**
  10942. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10943. * This specifies what angle the shadow will use to be created.
  10944. *
  10945. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10946. */
  10947. shadowAngle: number;
  10948. /**
  10949. * Gets the direction if it has been set.
  10950. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10951. */
  10952. /**
  10953. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10954. */
  10955. direction: Vector3;
  10956. /**
  10957. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  10958. * A PointLight emits the light in every direction.
  10959. * It can cast shadows.
  10960. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  10961. * ```javascript
  10962. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  10963. * ```
  10964. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10965. * @param name The light friendly name
  10966. * @param position The position of the point light in the scene
  10967. * @param scene The scene the lights belongs to
  10968. */
  10969. constructor(name: string, position: Vector3, scene: Scene);
  10970. /**
  10971. * Returns the string "PointLight"
  10972. * @returns the class name
  10973. */
  10974. getClassName(): string;
  10975. /**
  10976. * Returns the integer 0.
  10977. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10978. */
  10979. getTypeID(): number;
  10980. /**
  10981. * Specifies wether or not the shadowmap should be a cube texture.
  10982. * @returns true if the shadowmap needs to be a cube texture.
  10983. */
  10984. needCube(): boolean;
  10985. /**
  10986. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  10987. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10988. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10989. */
  10990. getShadowDirection(faceIndex?: number): Vector3;
  10991. /**
  10992. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  10993. * - fov = PI / 2
  10994. * - aspect ratio : 1.0
  10995. * - z-near and far equal to the active camera minZ and maxZ.
  10996. * Returns the PointLight.
  10997. */
  10998. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10999. protected _buildUniformLayout(): void;
  11000. /**
  11001. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11002. * @param effect The effect to update
  11003. * @param lightIndex The index of the light in the effect to update
  11004. * @returns The point light
  11005. */
  11006. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11007. }
  11008. }
  11009. declare module BABYLON {
  11010. /**
  11011. * Interface describing all the common properties and methods a shadow light needs to implement.
  11012. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11013. * as well as binding the different shadow properties to the effects.
  11014. */
  11015. interface IShadowLight extends Light {
  11016. /**
  11017. * The light id in the scene (used in scene.findLighById for instance)
  11018. */
  11019. id: string;
  11020. /**
  11021. * The position the shdow will be casted from.
  11022. */
  11023. position: Vector3;
  11024. /**
  11025. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11026. */
  11027. direction: Vector3;
  11028. /**
  11029. * The transformed position. Position of the light in world space taking parenting in account.
  11030. */
  11031. transformedPosition: Vector3;
  11032. /**
  11033. * The transformed direction. Direction of the light in world space taking parenting in account.
  11034. */
  11035. transformedDirection: Vector3;
  11036. /**
  11037. * The friendly name of the light in the scene.
  11038. */
  11039. name: string;
  11040. /**
  11041. * Defines the shadow projection clipping minimum z value.
  11042. */
  11043. shadowMinZ: number;
  11044. /**
  11045. * Defines the shadow projection clipping maximum z value.
  11046. */
  11047. shadowMaxZ: number;
  11048. /**
  11049. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11050. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11051. */
  11052. computeTransformedInformation(): boolean;
  11053. /**
  11054. * Gets the scene the light belongs to.
  11055. * @returns The scene
  11056. */
  11057. getScene(): Scene;
  11058. /**
  11059. * Callback defining a custom Projection Matrix Builder.
  11060. * This can be used to override the default projection matrix computation.
  11061. */
  11062. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11063. /**
  11064. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11065. * @param matrix The materix to updated with the projection information
  11066. * @param viewMatrix The transform matrix of the light
  11067. * @param renderList The list of mesh to render in the map
  11068. * @returns The current light
  11069. */
  11070. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11071. /**
  11072. * Gets the current depth scale used in ESM.
  11073. * @returns The scale
  11074. */
  11075. getDepthScale(): number;
  11076. /**
  11077. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11078. * @returns true if a cube texture needs to be use
  11079. */
  11080. needCube(): boolean;
  11081. /**
  11082. * Detects if the projection matrix requires to be recomputed this frame.
  11083. * @returns true if it requires to be recomputed otherwise, false.
  11084. */
  11085. needProjectionMatrixCompute(): boolean;
  11086. /**
  11087. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11088. */
  11089. forceProjectionMatrixCompute(): void;
  11090. /**
  11091. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11092. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11093. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11094. */
  11095. getShadowDirection(faceIndex?: number): Vector3;
  11096. /**
  11097. * Gets the minZ used for shadow according to both the scene and the light.
  11098. * @param activeCamera The camera we are returning the min for
  11099. * @returns the depth min z
  11100. */
  11101. getDepthMinZ(activeCamera: Camera): number;
  11102. /**
  11103. * Gets the maxZ used for shadow according to both the scene and the light.
  11104. * @param activeCamera The camera we are returning the max for
  11105. * @returns the depth max z
  11106. */
  11107. getDepthMaxZ(activeCamera: Camera): number;
  11108. }
  11109. /**
  11110. * Base implementation IShadowLight
  11111. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11112. */
  11113. abstract class ShadowLight extends Light implements IShadowLight {
  11114. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11115. protected _position: Vector3;
  11116. protected _setPosition(value: Vector3): void;
  11117. /**
  11118. * Sets the position the shadow will be casted from. Also use as the light position for both
  11119. * point and spot lights.
  11120. */
  11121. /**
  11122. * Sets the position the shadow will be casted from. Also use as the light position for both
  11123. * point and spot lights.
  11124. */
  11125. position: Vector3;
  11126. protected _direction: Vector3;
  11127. protected _setDirection(value: Vector3): void;
  11128. /**
  11129. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11130. * Also use as the light direction on spot and directional lights.
  11131. */
  11132. /**
  11133. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11134. * Also use as the light direction on spot and directional lights.
  11135. */
  11136. direction: Vector3;
  11137. private _shadowMinZ;
  11138. /**
  11139. * Gets the shadow projection clipping minimum z value.
  11140. */
  11141. /**
  11142. * Sets the shadow projection clipping minimum z value.
  11143. */
  11144. shadowMinZ: number;
  11145. private _shadowMaxZ;
  11146. /**
  11147. * Sets the shadow projection clipping maximum z value.
  11148. */
  11149. /**
  11150. * Gets the shadow projection clipping maximum z value.
  11151. */
  11152. shadowMaxZ: number;
  11153. /**
  11154. * Callback defining a custom Projection Matrix Builder.
  11155. * This can be used to override the default projection matrix computation.
  11156. */
  11157. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11158. /**
  11159. * The transformed position. Position of the light in world space taking parenting in account.
  11160. */
  11161. transformedPosition: Vector3;
  11162. /**
  11163. * The transformed direction. Direction of the light in world space taking parenting in account.
  11164. */
  11165. transformedDirection: Vector3;
  11166. private _worldMatrix;
  11167. private _needProjectionMatrixCompute;
  11168. /**
  11169. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11170. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11171. */
  11172. computeTransformedInformation(): boolean;
  11173. /**
  11174. * Return the depth scale used for the shadow map.
  11175. * @returns the depth scale.
  11176. */
  11177. getDepthScale(): number;
  11178. /**
  11179. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11180. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11181. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11182. */
  11183. getShadowDirection(faceIndex?: number): Vector3;
  11184. /**
  11185. * Returns the ShadowLight absolute position in the World.
  11186. * @returns the position vector in world space
  11187. */
  11188. getAbsolutePosition(): Vector3;
  11189. /**
  11190. * Sets the ShadowLight direction toward the passed target.
  11191. * @param target The point tot target in local space
  11192. * @returns the updated ShadowLight direction
  11193. */
  11194. setDirectionToTarget(target: Vector3): Vector3;
  11195. /**
  11196. * Returns the light rotation in euler definition.
  11197. * @returns the x y z rotation in local space.
  11198. */
  11199. getRotation(): Vector3;
  11200. /**
  11201. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11202. * @returns true if a cube texture needs to be use
  11203. */
  11204. needCube(): boolean;
  11205. /**
  11206. * Detects if the projection matrix requires to be recomputed this frame.
  11207. * @returns true if it requires to be recomputed otherwise, false.
  11208. */
  11209. needProjectionMatrixCompute(): boolean;
  11210. /**
  11211. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11212. */
  11213. forceProjectionMatrixCompute(): void;
  11214. /**
  11215. * Get the world matrix of the sahdow lights.
  11216. * @hidden Internal Use Only
  11217. */
  11218. _getWorldMatrix(): Matrix;
  11219. /**
  11220. * Gets the minZ used for shadow according to both the scene and the light.
  11221. * @param activeCamera The camera we are returning the min for
  11222. * @returns the depth min z
  11223. */
  11224. getDepthMinZ(activeCamera: Camera): number;
  11225. /**
  11226. * Gets the maxZ used for shadow according to both the scene and the light.
  11227. * @param activeCamera The camera we are returning the max for
  11228. * @returns the depth max z
  11229. */
  11230. getDepthMaxZ(activeCamera: Camera): number;
  11231. /**
  11232. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11233. * @param matrix The materix to updated with the projection information
  11234. * @param viewMatrix The transform matrix of the light
  11235. * @param renderList The list of mesh to render in the map
  11236. * @returns The current light
  11237. */
  11238. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11239. }
  11240. }
  11241. declare module BABYLON {
  11242. /**
  11243. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11244. * These values define a cone of light starting from the position, emitting toward the direction.
  11245. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11246. * and the exponent defines the speed of the decay of the light with distance (reach).
  11247. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11248. */
  11249. class SpotLight extends ShadowLight {
  11250. private _angle;
  11251. /**
  11252. * Gets the cone angle of the spot light in Radians.
  11253. */
  11254. /**
  11255. * Sets the cone angle of the spot light in Radians.
  11256. */
  11257. angle: number;
  11258. private _shadowAngleScale;
  11259. /**
  11260. * Allows scaling the angle of the light for shadow generation only.
  11261. */
  11262. /**
  11263. * Allows scaling the angle of the light for shadow generation only.
  11264. */
  11265. shadowAngleScale: number;
  11266. /**
  11267. * The light decay speed with the distance from the emission spot.
  11268. */
  11269. exponent: number;
  11270. private _projectionTextureMatrix;
  11271. /**
  11272. * Allows reading the projecton texture
  11273. */
  11274. readonly projectionTextureMatrix: Matrix;
  11275. protected _projectionTextureLightNear: number;
  11276. /**
  11277. * Gets the near clip of the Spotlight for texture projection.
  11278. */
  11279. /**
  11280. * Sets the near clip of the Spotlight for texture projection.
  11281. */
  11282. projectionTextureLightNear: number;
  11283. protected _projectionTextureLightFar: number;
  11284. /**
  11285. * Gets the far clip of the Spotlight for texture projection.
  11286. */
  11287. /**
  11288. * Sets the far clip of the Spotlight for texture projection.
  11289. */
  11290. projectionTextureLightFar: number;
  11291. protected _projectionTextureUpDirection: Vector3;
  11292. /**
  11293. * Gets the Up vector of the Spotlight for texture projection.
  11294. */
  11295. /**
  11296. * Sets the Up vector of the Spotlight for texture projection.
  11297. */
  11298. projectionTextureUpDirection: Vector3;
  11299. private _projectionTexture;
  11300. /**
  11301. * Gets the projection texture of the light.
  11302. */
  11303. /**
  11304. * Sets the projection texture of the light.
  11305. */
  11306. projectionTexture: Nullable<BaseTexture>;
  11307. private _projectionTextureViewLightDirty;
  11308. private _projectionTextureProjectionLightDirty;
  11309. private _projectionTextureDirty;
  11310. private _projectionTextureViewTargetVector;
  11311. private _projectionTextureViewLightMatrix;
  11312. private _projectionTextureProjectionLightMatrix;
  11313. private _projectionTextureScalingMatrix;
  11314. /**
  11315. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11316. * It can cast shadows.
  11317. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11318. * @param name The light friendly name
  11319. * @param position The position of the spot light in the scene
  11320. * @param direction The direction of the light in the scene
  11321. * @param angle The cone angle of the light in Radians
  11322. * @param exponent The light decay speed with the distance from the emission spot
  11323. * @param scene The scene the lights belongs to
  11324. */
  11325. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11326. /**
  11327. * Returns the string "SpotLight".
  11328. * @returns the class name
  11329. */
  11330. getClassName(): string;
  11331. /**
  11332. * Returns the integer 2.
  11333. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11334. */
  11335. getTypeID(): number;
  11336. /**
  11337. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11338. */
  11339. protected _setDirection(value: Vector3): void;
  11340. /**
  11341. * Overrides the position setter to recompute the projection texture view light Matrix.
  11342. */
  11343. protected _setPosition(value: Vector3): void;
  11344. /**
  11345. * 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.
  11346. * Returns the SpotLight.
  11347. */
  11348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11349. protected _computeProjectionTextureViewLightMatrix(): void;
  11350. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11351. /**
  11352. * Main function for light texture projection matrix computing.
  11353. */
  11354. protected _computeProjectionTextureMatrix(): void;
  11355. protected _buildUniformLayout(): void;
  11356. /**
  11357. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11358. * @param effect The effect to update
  11359. * @param lightIndex The index of the light in the effect to update
  11360. * @returns The spot light
  11361. */
  11362. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11363. /**
  11364. * Disposes the light and the associated resources.
  11365. */
  11366. dispose(): void;
  11367. }
  11368. }
  11369. declare module BABYLON {
  11370. /**
  11371. * Effect layer options. This helps customizing the behaviour
  11372. * of the effect layer.
  11373. */
  11374. interface IEffectLayerOptions {
  11375. /**
  11376. * Multiplication factor apply to the canvas size to compute the render target size
  11377. * used to generated the objects (the smaller the faster).
  11378. */
  11379. mainTextureRatio: number;
  11380. /**
  11381. * Enforces a fixed size texture to ensure effect stability across devices.
  11382. */
  11383. mainTextureFixedSize?: number;
  11384. /**
  11385. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  11386. */
  11387. alphaBlendingMode: number;
  11388. /**
  11389. * The camera attached to the layer.
  11390. */
  11391. camera: Nullable<Camera>;
  11392. }
  11393. /**
  11394. * The effect layer Helps adding post process effect blended with the main pass.
  11395. *
  11396. * This can be for instance use to generate glow or higlight effects on the scene.
  11397. *
  11398. * The effect layer class can not be used directly and is intented to inherited from to be
  11399. * customized per effects.
  11400. */
  11401. abstract class EffectLayer {
  11402. private _vertexBuffers;
  11403. private _indexBuffer;
  11404. private _cachedDefines;
  11405. private _effectLayerMapGenerationEffect;
  11406. private _effectLayerOptions;
  11407. private _mergeEffect;
  11408. protected _scene: Scene;
  11409. protected _engine: Engine;
  11410. protected _maxSize: number;
  11411. protected _mainTextureDesiredSize: ISize;
  11412. protected _mainTexture: RenderTargetTexture;
  11413. protected _shouldRender: boolean;
  11414. protected _postProcesses: PostProcess[];
  11415. protected _textures: BaseTexture[];
  11416. protected _emissiveTextureAndColor: {
  11417. texture: Nullable<BaseTexture>;
  11418. color: Color4;
  11419. };
  11420. /**
  11421. * The name of the layer
  11422. */
  11423. name: string;
  11424. /**
  11425. * The clear color of the texture used to generate the glow map.
  11426. */
  11427. neutralColor: Color4;
  11428. /**
  11429. * Specifies wether the highlight layer is enabled or not.
  11430. */
  11431. isEnabled: boolean;
  11432. /**
  11433. * Gets the camera attached to the layer.
  11434. */
  11435. readonly camera: Nullable<Camera>;
  11436. /**
  11437. * An event triggered when the effect layer has been disposed.
  11438. */
  11439. onDisposeObservable: Observable<EffectLayer>;
  11440. /**
  11441. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11442. */
  11443. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11444. /**
  11445. * An event triggered when the generated texture is being merged in the scene.
  11446. */
  11447. onBeforeComposeObservable: Observable<EffectLayer>;
  11448. /**
  11449. * An event triggered when the generated texture has been merged in the scene.
  11450. */
  11451. onAfterComposeObservable: Observable<EffectLayer>;
  11452. /**
  11453. * An event triggered when the efffect layer changes its size.
  11454. */
  11455. onSizeChangedObservable: Observable<EffectLayer>;
  11456. /**
  11457. * Instantiates a new effect Layer and references it in the scene.
  11458. * @param name The name of the layer
  11459. * @param scene The scene to use the layer in
  11460. */
  11461. constructor(
  11462. /** The Friendly of the effect in the scene */
  11463. name: string, scene: Scene);
  11464. /**
  11465. * Get the effect name of the layer.
  11466. * @return The effect name
  11467. */
  11468. abstract getEffectName(): string;
  11469. /**
  11470. * Checks for the readiness of the element composing the layer.
  11471. * @param subMesh the mesh to check for
  11472. * @param useInstances specify wether or not to use instances to render the mesh
  11473. * @return true if ready otherwise, false
  11474. */
  11475. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11476. /**
  11477. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11478. * @returns true if the effect requires stencil during the main canvas render pass.
  11479. */
  11480. abstract needStencil(): boolean;
  11481. /**
  11482. * Create the merge effect. This is the shader use to blit the information back
  11483. * to the main canvas at the end of the scene rendering.
  11484. * @returns The effect containing the shader used to merge the effect on the main canvas
  11485. */
  11486. protected abstract _createMergeEffect(): Effect;
  11487. /**
  11488. * Creates the render target textures and post processes used in the effect layer.
  11489. */
  11490. protected abstract _createTextureAndPostProcesses(): void;
  11491. /**
  11492. * Implementation specific of rendering the generating effect on the main canvas.
  11493. * @param effect The effect used to render through
  11494. */
  11495. protected abstract _internalRender(effect: Effect): void;
  11496. /**
  11497. * Sets the required values for both the emissive texture and and the main color.
  11498. */
  11499. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11500. /**
  11501. * Free any resources and references associated to a mesh.
  11502. * Internal use
  11503. * @param mesh The mesh to free.
  11504. */
  11505. abstract _disposeMesh(mesh: Mesh): void;
  11506. /**
  11507. * Serializes this layer (Glow or Highlight for example)
  11508. * @returns a serialized layer object
  11509. */
  11510. abstract serialize?(): any;
  11511. /**
  11512. * Initializes the effect layer with the required options.
  11513. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11514. */
  11515. protected _init(options: Partial<IEffectLayerOptions>): void;
  11516. /**
  11517. * Generates the index buffer of the full screen quad blending to the main canvas.
  11518. */
  11519. private _generateIndexBuffer();
  11520. /**
  11521. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11522. */
  11523. private _genrateVertexBuffer();
  11524. /**
  11525. * Sets the main texture desired size which is the closest power of two
  11526. * of the engine canvas size.
  11527. */
  11528. private _setMainTextureSize();
  11529. /**
  11530. * Creates the main texture for the effect layer.
  11531. */
  11532. protected _createMainTexture(): void;
  11533. /**
  11534. * Checks for the readiness of the element composing the layer.
  11535. * @param subMesh the mesh to check for
  11536. * @param useInstances specify wether or not to use instances to render the mesh
  11537. * @param emissiveTexture the associated emissive texture used to generate the glow
  11538. * @return true if ready otherwise, false
  11539. */
  11540. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11541. /**
  11542. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11543. */
  11544. render(): void;
  11545. /**
  11546. * Determine if a given mesh will be used in the current effect.
  11547. * @param mesh mesh to test
  11548. * @returns true if the mesh will be used
  11549. */
  11550. hasMesh(mesh: AbstractMesh): boolean;
  11551. /**
  11552. * Returns true if the layer contains information to display, otherwise false.
  11553. * @returns true if the glow layer should be rendered
  11554. */
  11555. shouldRender(): boolean;
  11556. /**
  11557. * Returns true if the mesh should render, otherwise false.
  11558. * @param mesh The mesh to render
  11559. * @returns true if it should render otherwise false
  11560. */
  11561. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11562. /**
  11563. * Returns true if the mesh should render, otherwise false.
  11564. * @param mesh The mesh to render
  11565. * @returns true if it should render otherwise false
  11566. */
  11567. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11568. /**
  11569. * Renders the submesh passed in parameter to the generation map.
  11570. */
  11571. protected _renderSubMesh(subMesh: SubMesh): void;
  11572. /**
  11573. * Rebuild the required buffers.
  11574. * @hidden Internal use only.
  11575. */
  11576. _rebuild(): void;
  11577. /**
  11578. * Dispose only the render target textures and post process.
  11579. */
  11580. private _disposeTextureAndPostProcesses();
  11581. /**
  11582. * Dispose the highlight layer and free resources.
  11583. */
  11584. dispose(): void;
  11585. /**
  11586. * Gets the class name of the effect layer
  11587. * @returns the string with the class name of the effect layer
  11588. */
  11589. getClassName(): string;
  11590. /**
  11591. * Creates an effect layer from parsed effect layer data
  11592. * @param parsedEffectLayer defines effect layer data
  11593. * @param scene defines the current scene
  11594. * @param rootUrl defines the root URL containing the effect layer information
  11595. * @returns a parsed effect Layer
  11596. */
  11597. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11598. }
  11599. }
  11600. declare module BABYLON {
  11601. /**
  11602. * Glow layer options. This helps customizing the behaviour
  11603. * of the glow layer.
  11604. */
  11605. interface IGlowLayerOptions {
  11606. /**
  11607. * Multiplication factor apply to the canvas size to compute the render target size
  11608. * used to generated the glowing objects (the smaller the faster).
  11609. */
  11610. mainTextureRatio: number;
  11611. /**
  11612. * Enforces a fixed size texture to ensure resize independant blur.
  11613. */
  11614. mainTextureFixedSize?: number;
  11615. /**
  11616. * How big is the kernel of the blur texture.
  11617. */
  11618. blurKernelSize: number;
  11619. /**
  11620. * The camera attached to the layer.
  11621. */
  11622. camera: Nullable<Camera>;
  11623. /**
  11624. * Enable MSAA by chosing the number of samples.
  11625. */
  11626. mainTextureSamples?: number;
  11627. }
  11628. /**
  11629. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11630. *
  11631. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11632. * glowy meshes to your scene.
  11633. *
  11634. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11635. */
  11636. class GlowLayer extends EffectLayer {
  11637. /**
  11638. * Effect Name of the layer.
  11639. */
  11640. static readonly EffectName: string;
  11641. /**
  11642. * The default blur kernel size used for the glow.
  11643. */
  11644. static DefaultBlurKernelSize: number;
  11645. /**
  11646. * The default texture size ratio used for the glow.
  11647. */
  11648. static DefaultTextureRatio: number;
  11649. /**
  11650. * Gets the kernel size of the blur.
  11651. */
  11652. /**
  11653. * Sets the kernel size of the blur.
  11654. */
  11655. blurKernelSize: number;
  11656. /**
  11657. * Gets the glow intensity.
  11658. */
  11659. /**
  11660. * Sets the glow intensity.
  11661. */
  11662. intensity: number;
  11663. private _options;
  11664. private _intensity;
  11665. private _horizontalBlurPostprocess1;
  11666. private _verticalBlurPostprocess1;
  11667. private _horizontalBlurPostprocess2;
  11668. private _verticalBlurPostprocess2;
  11669. private _blurTexture1;
  11670. private _blurTexture2;
  11671. private _postProcesses1;
  11672. private _postProcesses2;
  11673. private _includedOnlyMeshes;
  11674. private _excludedMeshes;
  11675. /**
  11676. * Callback used to let the user override the color selection on a per mesh basis
  11677. */
  11678. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11679. /**
  11680. * Callback used to let the user override the texture selection on a per mesh basis
  11681. */
  11682. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11683. /**
  11684. * Instantiates a new glow Layer and references it to the scene.
  11685. * @param name The name of the layer
  11686. * @param scene The scene to use the layer in
  11687. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11688. */
  11689. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11690. /**
  11691. * Get the effect name of the layer.
  11692. * @return The effect name
  11693. */
  11694. getEffectName(): string;
  11695. /**
  11696. * Create the merge effect. This is the shader use to blit the information back
  11697. * to the main canvas at the end of the scene rendering.
  11698. */
  11699. protected _createMergeEffect(): Effect;
  11700. /**
  11701. * Creates the render target textures and post processes used in the glow layer.
  11702. */
  11703. protected _createTextureAndPostProcesses(): void;
  11704. /**
  11705. * Checks for the readiness of the element composing the layer.
  11706. * @param subMesh the mesh to check for
  11707. * @param useInstances specify wether or not to use instances to render the mesh
  11708. * @param emissiveTexture the associated emissive texture used to generate the glow
  11709. * @return true if ready otherwise, false
  11710. */
  11711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11712. /**
  11713. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11714. */
  11715. needStencil(): boolean;
  11716. /**
  11717. * Implementation specific of rendering the generating effect on the main canvas.
  11718. * @param effect The effect used to render through
  11719. */
  11720. protected _internalRender(effect: Effect): void;
  11721. /**
  11722. * Sets the required values for both the emissive texture and and the main color.
  11723. */
  11724. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11725. /**
  11726. * Returns true if the mesh should render, otherwise false.
  11727. * @param mesh The mesh to render
  11728. * @returns true if it should render otherwise false
  11729. */
  11730. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11731. /**
  11732. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11733. * @param mesh The mesh to exclude from the glow layer
  11734. */
  11735. addExcludedMesh(mesh: Mesh): void;
  11736. /**
  11737. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11738. * @param mesh The mesh to remove
  11739. */
  11740. removeExcludedMesh(mesh: Mesh): void;
  11741. /**
  11742. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11743. * @param mesh The mesh to include in the glow layer
  11744. */
  11745. addIncludedOnlyMesh(mesh: Mesh): void;
  11746. /**
  11747. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11748. * @param mesh The mesh to remove
  11749. */
  11750. removeIncludedOnlyMesh(mesh: Mesh): void;
  11751. /**
  11752. * Determine if a given mesh will be used in the glow layer
  11753. * @param mesh The mesh to test
  11754. * @returns true if the mesh will be highlighted by the current glow layer
  11755. */
  11756. hasMesh(mesh: AbstractMesh): boolean;
  11757. /**
  11758. * Free any resources and references associated to a mesh.
  11759. * Internal use
  11760. * @param mesh The mesh to free.
  11761. */
  11762. _disposeMesh(mesh: Mesh): void;
  11763. /**
  11764. * Gets the class name of the effect layer
  11765. * @returns the string with the class name of the effect layer
  11766. */
  11767. getClassName(): string;
  11768. /**
  11769. * Serializes this glow layer
  11770. * @returns a serialized glow layer object
  11771. */
  11772. serialize(): any;
  11773. /**
  11774. * Creates a Glow Layer from parsed glow layer data
  11775. * @param parsedGlowLayer defines glow layer data
  11776. * @param scene defines the current scene
  11777. * @param rootUrl defines the root URL containing the glow layer information
  11778. * @returns a parsed Glow Layer
  11779. */
  11780. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11781. }
  11782. }
  11783. declare module BABYLON {
  11784. /**
  11785. * Highlight layer options. This helps customizing the behaviour
  11786. * of the highlight layer.
  11787. */
  11788. interface IHighlightLayerOptions {
  11789. /**
  11790. * Multiplication factor apply to the canvas size to compute the render target size
  11791. * used to generated the glowing objects (the smaller the faster).
  11792. */
  11793. mainTextureRatio: number;
  11794. /**
  11795. * Enforces a fixed size texture to ensure resize independant blur.
  11796. */
  11797. mainTextureFixedSize?: number;
  11798. /**
  11799. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11800. * of the picture to blur (the smaller the faster).
  11801. */
  11802. blurTextureSizeRatio: number;
  11803. /**
  11804. * How big in texel of the blur texture is the vertical blur.
  11805. */
  11806. blurVerticalSize: number;
  11807. /**
  11808. * How big in texel of the blur texture is the horizontal blur.
  11809. */
  11810. blurHorizontalSize: number;
  11811. /**
  11812. * Alpha blending mode used to apply the blur. Default is combine.
  11813. */
  11814. alphaBlendingMode: number;
  11815. /**
  11816. * The camera attached to the layer.
  11817. */
  11818. camera: Nullable<Camera>;
  11819. /**
  11820. * Should we display highlight as a solid stroke?
  11821. */
  11822. isStroke?: boolean;
  11823. }
  11824. /**
  11825. * The highlight layer Helps adding a glow effect around a mesh.
  11826. *
  11827. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11828. * glowy meshes to your scene.
  11829. *
  11830. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11831. */
  11832. class HighlightLayer extends EffectLayer {
  11833. name: string;
  11834. /**
  11835. * Effect Name of the highlight layer.
  11836. */
  11837. static readonly EffectName: string;
  11838. /**
  11839. * The neutral color used during the preparation of the glow effect.
  11840. * This is black by default as the blend operation is a blend operation.
  11841. */
  11842. static NeutralColor: Color4;
  11843. /**
  11844. * Stencil value used for glowing meshes.
  11845. */
  11846. static GlowingMeshStencilReference: number;
  11847. /**
  11848. * Stencil value used for the other meshes in the scene.
  11849. */
  11850. static NormalMeshStencilReference: number;
  11851. /**
  11852. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11853. */
  11854. innerGlow: boolean;
  11855. /**
  11856. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11857. */
  11858. outerGlow: boolean;
  11859. /**
  11860. * Gets the horizontal size of the blur.
  11861. */
  11862. /**
  11863. * Specifies the horizontal size of the blur.
  11864. */
  11865. blurHorizontalSize: number;
  11866. /**
  11867. * Gets the vertical size of the blur.
  11868. */
  11869. /**
  11870. * Specifies the vertical size of the blur.
  11871. */
  11872. blurVerticalSize: number;
  11873. /**
  11874. * An event triggered when the highlight layer is being blurred.
  11875. */
  11876. onBeforeBlurObservable: Observable<HighlightLayer>;
  11877. /**
  11878. * An event triggered when the highlight layer has been blurred.
  11879. */
  11880. onAfterBlurObservable: Observable<HighlightLayer>;
  11881. private _instanceGlowingMeshStencilReference;
  11882. private _options;
  11883. private _downSamplePostprocess;
  11884. private _horizontalBlurPostprocess;
  11885. private _verticalBlurPostprocess;
  11886. private _blurTexture;
  11887. private _meshes;
  11888. private _excludedMeshes;
  11889. /**
  11890. * Instantiates a new highlight Layer and references it to the scene..
  11891. * @param name The name of the layer
  11892. * @param scene The scene to use the layer in
  11893. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11894. */
  11895. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11896. /**
  11897. * Get the effect name of the layer.
  11898. * @return The effect name
  11899. */
  11900. getEffectName(): string;
  11901. /**
  11902. * Create the merge effect. This is the shader use to blit the information back
  11903. * to the main canvas at the end of the scene rendering.
  11904. */
  11905. protected _createMergeEffect(): Effect;
  11906. /**
  11907. * Creates the render target textures and post processes used in the highlight layer.
  11908. */
  11909. protected _createTextureAndPostProcesses(): void;
  11910. /**
  11911. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11912. */
  11913. needStencil(): boolean;
  11914. /**
  11915. * Checks for the readiness of the element composing the layer.
  11916. * @param subMesh the mesh to check for
  11917. * @param useInstances specify wether or not to use instances to render the mesh
  11918. * @param emissiveTexture the associated emissive texture used to generate the glow
  11919. * @return true if ready otherwise, false
  11920. */
  11921. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11922. /**
  11923. * Implementation specific of rendering the generating effect on the main canvas.
  11924. * @param effect The effect used to render through
  11925. */
  11926. protected _internalRender(effect: Effect): void;
  11927. /**
  11928. * Returns true if the layer contains information to display, otherwise false.
  11929. */
  11930. shouldRender(): boolean;
  11931. /**
  11932. * Returns true if the mesh should render, otherwise false.
  11933. * @param mesh The mesh to render
  11934. * @returns true if it should render otherwise false
  11935. */
  11936. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11937. /**
  11938. * Sets the required values for both the emissive texture and and the main color.
  11939. */
  11940. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11941. /**
  11942. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11943. * @param mesh The mesh to exclude from the highlight layer
  11944. */
  11945. addExcludedMesh(mesh: Mesh): void;
  11946. /**
  11947. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11948. * @param mesh The mesh to highlight
  11949. */
  11950. removeExcludedMesh(mesh: Mesh): void;
  11951. /**
  11952. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11953. * @param mesh mesh to test
  11954. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11955. */
  11956. hasMesh(mesh: AbstractMesh): boolean;
  11957. /**
  11958. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11959. * @param mesh The mesh to highlight
  11960. * @param color The color of the highlight
  11961. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11962. */
  11963. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11964. /**
  11965. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11966. * @param mesh The mesh to highlight
  11967. */
  11968. removeMesh(mesh: Mesh): void;
  11969. /**
  11970. * Force the stencil to the normal expected value for none glowing parts
  11971. */
  11972. private _defaultStencilReference(mesh);
  11973. /**
  11974. * Free any resources and references associated to a mesh.
  11975. * Internal use
  11976. * @param mesh The mesh to free.
  11977. */
  11978. _disposeMesh(mesh: Mesh): void;
  11979. /**
  11980. * Dispose the highlight layer and free resources.
  11981. */
  11982. dispose(): void;
  11983. /**
  11984. * Gets the class name of the effect layer
  11985. * @returns the string with the class name of the effect layer
  11986. */
  11987. getClassName(): string;
  11988. /**
  11989. * Serializes this Highlight layer
  11990. * @returns a serialized Highlight layer object
  11991. */
  11992. serialize(): any;
  11993. /**
  11994. * Creates a Highlight layer from parsed Highlight layer data
  11995. * @param parsedHightlightLayer defines the Highlight layer data
  11996. * @param scene defines the current scene
  11997. * @param rootUrl defines the root URL containing the Highlight layer information
  11998. * @returns a parsed Highlight layer
  11999. */
  12000. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  12001. }
  12002. }
  12003. declare module BABYLON {
  12004. class Layer {
  12005. name: string;
  12006. texture: Nullable<Texture>;
  12007. isBackground: boolean;
  12008. color: Color4;
  12009. scale: Vector2;
  12010. offset: Vector2;
  12011. alphaBlendingMode: number;
  12012. alphaTest: boolean;
  12013. layerMask: number;
  12014. private _scene;
  12015. private _vertexBuffers;
  12016. private _indexBuffer;
  12017. private _effect;
  12018. private _alphaTestEffect;
  12019. /**
  12020. * An event triggered when the layer is disposed.
  12021. */
  12022. onDisposeObservable: Observable<Layer>;
  12023. private _onDisposeObserver;
  12024. onDispose: () => void;
  12025. /**
  12026. * An event triggered before rendering the scene
  12027. */
  12028. onBeforeRenderObservable: Observable<Layer>;
  12029. private _onBeforeRenderObserver;
  12030. onBeforeRender: () => void;
  12031. /**
  12032. * An event triggered after rendering the scene
  12033. */
  12034. onAfterRenderObservable: Observable<Layer>;
  12035. private _onAfterRenderObserver;
  12036. onAfterRender: () => void;
  12037. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  12038. private _createIndexBuffer();
  12039. _rebuild(): void;
  12040. render(): void;
  12041. dispose(): void;
  12042. }
  12043. }
  12044. declare module BABYLON {
  12045. interface ILoadingScreen {
  12046. displayLoadingUI: () => void;
  12047. hideLoadingUI: () => void;
  12048. loadingUIBackgroundColor: string;
  12049. loadingUIText: string;
  12050. }
  12051. class DefaultLoadingScreen implements ILoadingScreen {
  12052. private _renderingCanvas;
  12053. private _loadingText;
  12054. private _loadingDivBackgroundColor;
  12055. private _loadingDiv;
  12056. private _loadingTextDiv;
  12057. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12058. displayLoadingUI(): void;
  12059. hideLoadingUI(): void;
  12060. loadingUIText: string;
  12061. loadingUIBackgroundColor: string;
  12062. private _resizeLoadingUI;
  12063. }
  12064. }
  12065. declare module BABYLON {
  12066. class SceneLoaderProgressEvent {
  12067. readonly lengthComputable: boolean;
  12068. readonly loaded: number;
  12069. readonly total: number;
  12070. constructor(lengthComputable: boolean, loaded: number, total: number);
  12071. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12072. }
  12073. interface ISceneLoaderPluginExtensions {
  12074. [extension: string]: {
  12075. isBinary: boolean;
  12076. };
  12077. }
  12078. interface ISceneLoaderPluginFactory {
  12079. name: string;
  12080. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12081. canDirectLoad?: (data: string) => boolean;
  12082. }
  12083. interface ISceneLoaderPlugin {
  12084. /**
  12085. * The friendly name of this plugin.
  12086. */
  12087. name: string;
  12088. /**
  12089. * The file extensions supported by this plugin.
  12090. */
  12091. extensions: string | ISceneLoaderPluginExtensions;
  12092. /**
  12093. * Import meshes into a scene.
  12094. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12095. * @param scene The scene to import into
  12096. * @param data The data to import
  12097. * @param rootUrl The root url for scene and resources
  12098. * @param meshes The meshes array to import into
  12099. * @param particleSystems The particle systems array to import into
  12100. * @param skeletons The skeletons array to import into
  12101. * @param onError The callback when import fails
  12102. * @returns True if successful or false otherwise
  12103. */
  12104. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12105. /**
  12106. * Load into a scene.
  12107. * @param scene The scene to load into
  12108. * @param data The data to import
  12109. * @param rootUrl The root url for scene and resources
  12110. * @param onError The callback when import fails
  12111. * @returns true if successful or false otherwise
  12112. */
  12113. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12114. /**
  12115. * The callback that returns true if the data can be directly loaded.
  12116. */
  12117. canDirectLoad?: (data: string) => boolean;
  12118. /**
  12119. * The callback that allows custom handling of the root url based on the response url.
  12120. */
  12121. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12122. /**
  12123. * Load into an asset container.
  12124. * @param scene The scene to load into
  12125. * @param data The data to import
  12126. * @param rootUrl The root url for scene and resources
  12127. * @param onError The callback when import fails
  12128. * @returns The loaded asset container
  12129. */
  12130. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12131. }
  12132. interface ISceneLoaderPluginAsync {
  12133. /**
  12134. * The friendly name of this plugin.
  12135. */
  12136. name: string;
  12137. /**
  12138. * The file extensions supported by this plugin.
  12139. */
  12140. extensions: string | ISceneLoaderPluginExtensions;
  12141. /**
  12142. * Import meshes into a scene.
  12143. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12144. * @param scene The scene to import into
  12145. * @param data The data to import
  12146. * @param rootUrl The root url for scene and resources
  12147. * @param onProgress The callback when the load progresses
  12148. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12149. */
  12150. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12151. meshes: AbstractMesh[];
  12152. particleSystems: ParticleSystem[];
  12153. skeletons: Skeleton[];
  12154. animationGroups: AnimationGroup[];
  12155. }>;
  12156. /**
  12157. * Load into a scene.
  12158. * @param scene The scene to load into
  12159. * @param data The data to import
  12160. * @param rootUrl The root url for scene and resources
  12161. * @param onProgress The callback when the load progresses
  12162. * @returns Nothing
  12163. */
  12164. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12165. /**
  12166. * The callback that returns true if the data can be directly loaded.
  12167. */
  12168. canDirectLoad?: (data: string) => boolean;
  12169. /**
  12170. * The callback that allows custom handling of the root url based on the response url.
  12171. */
  12172. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12173. /**
  12174. * Load into an asset container.
  12175. * @param scene The scene to load into
  12176. * @param data The data to import
  12177. * @param rootUrl The root url for scene and resources
  12178. * @param onProgress The callback when the load progresses
  12179. * @returns The loaded asset container
  12180. */
  12181. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12182. }
  12183. class SceneLoader {
  12184. private static _ForceFullSceneLoadingForIncremental;
  12185. private static _ShowLoadingScreen;
  12186. private static _CleanBoneMatrixWeights;
  12187. static readonly NO_LOGGING: number;
  12188. static readonly MINIMAL_LOGGING: number;
  12189. static readonly SUMMARY_LOGGING: number;
  12190. static readonly DETAILED_LOGGING: number;
  12191. private static _loggingLevel;
  12192. static ForceFullSceneLoadingForIncremental: boolean;
  12193. static ShowLoadingScreen: boolean;
  12194. static loggingLevel: number;
  12195. static CleanBoneMatrixWeights: boolean;
  12196. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12197. private static _registeredPlugins;
  12198. private static _getDefaultPlugin();
  12199. private static _getPluginForExtension(extension);
  12200. private static _getPluginForDirectLoad(data);
  12201. private static _getPluginForFilename(sceneFilename);
  12202. private static _getDirectLoad(sceneFilename);
  12203. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12204. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12205. static IsPluginForExtensionAvailable(extension: string): boolean;
  12206. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12207. /**
  12208. * Import meshes into a scene
  12209. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12210. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12211. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12212. * @param scene the instance of BABYLON.Scene to append to
  12213. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12214. * @param onProgress a callback with a progress event for each file being loaded
  12215. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12216. * @param pluginExtension the extension used to determine the plugin
  12217. * @returns The loaded plugin
  12218. */
  12219. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12220. /**
  12221. * Import meshes into a scene
  12222. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12223. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12224. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12225. * @param scene the instance of BABYLON.Scene to append to
  12226. * @param onProgress a callback with a progress event for each file being loaded
  12227. * @param pluginExtension the extension used to determine the plugin
  12228. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12229. */
  12230. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12231. meshes: AbstractMesh[];
  12232. particleSystems: ParticleSystem[];
  12233. skeletons: Skeleton[];
  12234. animationGroups: AnimationGroup[];
  12235. }>;
  12236. /**
  12237. * Load a scene
  12238. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12239. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12240. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12241. * @param onSuccess a callback with the scene when import succeeds
  12242. * @param onProgress a callback with a progress event for each file being loaded
  12243. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12244. * @param pluginExtension the extension used to determine the plugin
  12245. * @returns The loaded plugin
  12246. */
  12247. 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>;
  12248. /**
  12249. * Load a scene
  12250. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12251. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12252. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12253. * @param onProgress a callback with a progress event for each file being loaded
  12254. * @param pluginExtension the extension used to determine the plugin
  12255. * @returns The loaded scene
  12256. */
  12257. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12258. /**
  12259. * Append a scene
  12260. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12261. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12262. * @param scene is the instance of BABYLON.Scene to append to
  12263. * @param onSuccess a callback with the scene when import succeeds
  12264. * @param onProgress a callback with a progress event for each file being loaded
  12265. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12266. * @param pluginExtension the extension used to determine the plugin
  12267. * @returns The loaded plugin
  12268. */
  12269. static Append(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12270. /**
  12271. * Append a scene
  12272. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12273. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12274. * @param scene is the instance of BABYLON.Scene to append to
  12275. * @param onProgress a callback with a progress event for each file being loaded
  12276. * @param pluginExtension the extension used to determine the plugin
  12277. * @returns The given scene
  12278. */
  12279. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12280. /**
  12281. * Load a scene into an asset container
  12282. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12283. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12284. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12285. * @param onSuccess a callback with the scene when import succeeds
  12286. * @param onProgress a callback with a progress event for each file being loaded
  12287. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12288. * @param pluginExtension the extension used to determine the plugin
  12289. * @returns The loaded plugin
  12290. */
  12291. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12292. /**
  12293. * Load a scene into an asset container
  12294. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12295. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12296. * @param scene is the instance of BABYLON.Scene to append to
  12297. * @param onProgress a callback with a progress event for each file being loaded
  12298. * @param pluginExtension the extension used to determine the plugin
  12299. * @returns The loaded asset container
  12300. */
  12301. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12302. }
  12303. }
  12304. declare module BABYLON {
  12305. /**
  12306. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12308. * 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;
  12309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12310. */
  12311. class ColorCurves {
  12312. private _dirty;
  12313. private _tempColor;
  12314. private _globalCurve;
  12315. private _highlightsCurve;
  12316. private _midtonesCurve;
  12317. private _shadowsCurve;
  12318. private _positiveCurve;
  12319. private _negativeCurve;
  12320. private _globalHue;
  12321. private _globalDensity;
  12322. private _globalSaturation;
  12323. private _globalExposure;
  12324. /**
  12325. * Gets the global Hue value.
  12326. * 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).
  12327. */
  12328. /**
  12329. * Sets the global Hue value.
  12330. * 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).
  12331. */
  12332. globalHue: number;
  12333. /**
  12334. * Gets the global Density value.
  12335. * 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.
  12336. * Values less than zero provide a filter of opposite hue.
  12337. */
  12338. /**
  12339. * Sets the global Density value.
  12340. * 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.
  12341. * Values less than zero provide a filter of opposite hue.
  12342. */
  12343. globalDensity: number;
  12344. /**
  12345. * Gets the global Saturation value.
  12346. * 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.
  12347. */
  12348. /**
  12349. * Sets the global Saturation value.
  12350. * 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.
  12351. */
  12352. globalSaturation: number;
  12353. /**
  12354. * Gets the global Exposure value.
  12355. * 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.
  12356. */
  12357. /**
  12358. * Sets the global Exposure value.
  12359. * 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.
  12360. */
  12361. globalExposure: number;
  12362. private _highlightsHue;
  12363. private _highlightsDensity;
  12364. private _highlightsSaturation;
  12365. private _highlightsExposure;
  12366. /**
  12367. * Gets the highlights Hue value.
  12368. * 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).
  12369. */
  12370. /**
  12371. * Sets the highlights Hue value.
  12372. * 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).
  12373. */
  12374. highlightsHue: number;
  12375. /**
  12376. * Gets the highlights Density value.
  12377. * 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.
  12378. * Values less than zero provide a filter of opposite hue.
  12379. */
  12380. /**
  12381. * Sets the highlights Density value.
  12382. * 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.
  12383. * Values less than zero provide a filter of opposite hue.
  12384. */
  12385. highlightsDensity: number;
  12386. /**
  12387. * Gets the highlights Saturation value.
  12388. * 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.
  12389. */
  12390. /**
  12391. * Sets the highlights Saturation value.
  12392. * 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.
  12393. */
  12394. highlightsSaturation: number;
  12395. /**
  12396. * Gets the highlights Exposure value.
  12397. * 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.
  12398. */
  12399. /**
  12400. * Sets the highlights Exposure value.
  12401. * 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.
  12402. */
  12403. highlightsExposure: number;
  12404. private _midtonesHue;
  12405. private _midtonesDensity;
  12406. private _midtonesSaturation;
  12407. private _midtonesExposure;
  12408. /**
  12409. * Gets the midtones Hue value.
  12410. * 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).
  12411. */
  12412. /**
  12413. * Sets the midtones Hue value.
  12414. * 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).
  12415. */
  12416. midtonesHue: number;
  12417. /**
  12418. * Gets the midtones Density value.
  12419. * 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.
  12420. * Values less than zero provide a filter of opposite hue.
  12421. */
  12422. /**
  12423. * Sets the midtones Density value.
  12424. * 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.
  12425. * Values less than zero provide a filter of opposite hue.
  12426. */
  12427. midtonesDensity: number;
  12428. /**
  12429. * Gets the midtones Saturation value.
  12430. * 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.
  12431. */
  12432. /**
  12433. * Sets the midtones Saturation value.
  12434. * 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.
  12435. */
  12436. midtonesSaturation: number;
  12437. /**
  12438. * Gets the midtones Exposure value.
  12439. * 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.
  12440. */
  12441. /**
  12442. * Sets the midtones Exposure value.
  12443. * 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.
  12444. */
  12445. midtonesExposure: number;
  12446. private _shadowsHue;
  12447. private _shadowsDensity;
  12448. private _shadowsSaturation;
  12449. private _shadowsExposure;
  12450. /**
  12451. * Gets the shadows Hue value.
  12452. * 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).
  12453. */
  12454. /**
  12455. * Sets the shadows Hue value.
  12456. * 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).
  12457. */
  12458. shadowsHue: number;
  12459. /**
  12460. * Gets the shadows Density value.
  12461. * 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.
  12462. * Values less than zero provide a filter of opposite hue.
  12463. */
  12464. /**
  12465. * Sets the shadows Density value.
  12466. * 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.
  12467. * Values less than zero provide a filter of opposite hue.
  12468. */
  12469. shadowsDensity: number;
  12470. /**
  12471. * Gets the shadows Saturation value.
  12472. * 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.
  12473. */
  12474. /**
  12475. * Sets the shadows Saturation value.
  12476. * 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.
  12477. */
  12478. shadowsSaturation: number;
  12479. /**
  12480. * Gets the shadows Exposure value.
  12481. * 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.
  12482. */
  12483. /**
  12484. * Sets the shadows Exposure value.
  12485. * 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.
  12486. */
  12487. shadowsExposure: number;
  12488. getClassName(): string;
  12489. /**
  12490. * Binds the color curves to the shader.
  12491. * @param colorCurves The color curve to bind
  12492. * @param effect The effect to bind to
  12493. */
  12494. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12495. /**
  12496. * Prepare the list of uniforms associated with the ColorCurves effects.
  12497. * @param uniformsList The list of uniforms used in the effect
  12498. */
  12499. static PrepareUniforms(uniformsList: string[]): void;
  12500. /**
  12501. * Returns color grading data based on a hue, density, saturation and exposure value.
  12502. * @param filterHue The hue of the color filter.
  12503. * @param filterDensity The density of the color filter.
  12504. * @param saturation The saturation.
  12505. * @param exposure The exposure.
  12506. * @param result The result data container.
  12507. */
  12508. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12509. /**
  12510. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12511. * @param value The input slider value in range [-100,100].
  12512. * @returns Adjusted value.
  12513. */
  12514. private static applyColorGradingSliderNonlinear(value);
  12515. /**
  12516. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12517. * @param hue The hue (H) input.
  12518. * @param saturation The saturation (S) input.
  12519. * @param brightness The brightness (B) input.
  12520. * @result An RGBA color represented as Vector4.
  12521. */
  12522. private static fromHSBToRef(hue, saturation, brightness, result);
  12523. /**
  12524. * Returns a value clamped between min and max
  12525. * @param value The value to clamp
  12526. * @param min The minimum of value
  12527. * @param max The maximum of value
  12528. * @returns The clamped value.
  12529. */
  12530. private static clamp(value, min, max);
  12531. /**
  12532. * Clones the current color curve instance.
  12533. * @return The cloned curves
  12534. */
  12535. clone(): ColorCurves;
  12536. /**
  12537. * Serializes the current color curve instance to a json representation.
  12538. * @return a JSON representation
  12539. */
  12540. serialize(): any;
  12541. /**
  12542. * Parses the color curve from a json representation.
  12543. * @param source the JSON source to parse
  12544. * @return The parsed curves
  12545. */
  12546. static Parse(source: any): ColorCurves;
  12547. }
  12548. }
  12549. declare module BABYLON {
  12550. /**
  12551. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12552. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12553. */
  12554. class EffectFallbacks {
  12555. private _defines;
  12556. private _currentRank;
  12557. private _maxRank;
  12558. private _mesh;
  12559. /**
  12560. * Removes the fallback from the bound mesh.
  12561. */
  12562. unBindMesh(): void;
  12563. /**
  12564. * Adds a fallback on the specified property.
  12565. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12566. * @param define The name of the define in the shader
  12567. */
  12568. addFallback(rank: number, define: string): void;
  12569. /**
  12570. * Sets the mesh to use CPU skinning when needing to fallback.
  12571. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12572. * @param mesh The mesh to use the fallbacks.
  12573. */
  12574. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12575. /**
  12576. * Checks to see if more fallbacks are still availible.
  12577. */
  12578. readonly isMoreFallbacks: boolean;
  12579. /**
  12580. * Removes the defines that shoould be removed when falling back.
  12581. * @param currentDefines defines the current define statements for the shader.
  12582. * @param effect defines the current effect we try to compile
  12583. * @returns The resulting defines with defines of the current rank removed.
  12584. */
  12585. reduce(currentDefines: string, effect: Effect): string;
  12586. }
  12587. /**
  12588. * Options to be used when creating an effect.
  12589. */
  12590. class EffectCreationOptions {
  12591. /**
  12592. * Atrributes that will be used in the shader.
  12593. */
  12594. attributes: string[];
  12595. /**
  12596. * Uniform varible names that will be set in the shader.
  12597. */
  12598. uniformsNames: string[];
  12599. /**
  12600. * Uniform buffer varible names that will be set in the shader.
  12601. */
  12602. uniformBuffersNames: string[];
  12603. /**
  12604. * Sampler texture variable names that will be set in the shader.
  12605. */
  12606. samplers: string[];
  12607. /**
  12608. * Define statements that will be set in the shader.
  12609. */
  12610. defines: any;
  12611. /**
  12612. * Possible fallbacks for this effect to improve performance when needed.
  12613. */
  12614. fallbacks: Nullable<EffectFallbacks>;
  12615. /**
  12616. * Callback that will be called when the shader is compiled.
  12617. */
  12618. onCompiled: Nullable<(effect: Effect) => void>;
  12619. /**
  12620. * Callback that will be called if an error occurs during shader compilation.
  12621. */
  12622. onError: Nullable<(effect: Effect, errors: string) => void>;
  12623. /**
  12624. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12625. */
  12626. indexParameters: any;
  12627. /**
  12628. * Max number of lights that can be used in the shader.
  12629. */
  12630. maxSimultaneousLights: number;
  12631. /**
  12632. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12633. */
  12634. transformFeedbackVaryings: Nullable<string[]>;
  12635. }
  12636. /**
  12637. * Effect containing vertex and fragment shader that can be executed on an object.
  12638. */
  12639. class Effect {
  12640. /**
  12641. * Name of the effect.
  12642. */
  12643. name: any;
  12644. /**
  12645. * String container all the define statements that should be set on the shader.
  12646. */
  12647. defines: string;
  12648. /**
  12649. * Callback that will be called when the shader is compiled.
  12650. */
  12651. onCompiled: Nullable<(effect: Effect) => void>;
  12652. /**
  12653. * Callback that will be called if an error occurs during shader compilation.
  12654. */
  12655. onError: Nullable<(effect: Effect, errors: string) => void>;
  12656. /**
  12657. * Callback that will be called when effect is bound.
  12658. */
  12659. onBind: Nullable<(effect: Effect) => void>;
  12660. /**
  12661. * Unique ID of the effect.
  12662. */
  12663. uniqueId: number;
  12664. /**
  12665. * Observable that will be called when the shader is compiled.
  12666. */
  12667. onCompileObservable: Observable<Effect>;
  12668. /**
  12669. * Observable that will be called if an error occurs during shader compilation.
  12670. */
  12671. onErrorObservable: Observable<Effect>;
  12672. /**
  12673. * Observable that will be called when effect is bound.
  12674. */
  12675. onBindObservable: Observable<Effect>;
  12676. /** @hidden */
  12677. _bonesComputationForcedToCPU: boolean;
  12678. private static _uniqueIdSeed;
  12679. private _engine;
  12680. private _uniformBuffersNames;
  12681. private _uniformsNames;
  12682. private _samplers;
  12683. private _isReady;
  12684. private _compilationError;
  12685. private _attributesNames;
  12686. private _attributes;
  12687. private _uniforms;
  12688. /**
  12689. * Key for the effect.
  12690. */
  12691. _key: string;
  12692. private _indexParameters;
  12693. private _fallbacks;
  12694. private _vertexSourceCode;
  12695. private _fragmentSourceCode;
  12696. private _vertexSourceCodeOverride;
  12697. private _fragmentSourceCodeOverride;
  12698. private _transformFeedbackVaryings;
  12699. /**
  12700. * Compiled shader to webGL program.
  12701. */
  12702. _program: WebGLProgram;
  12703. private _valueCache;
  12704. private static _baseCache;
  12705. /**
  12706. * Instantiates an effect.
  12707. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12708. * @param baseName Name of the effect.
  12709. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12710. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12711. * @param samplers List of sampler variables that will be passed to the shader.
  12712. * @param engine Engine to be used to render the effect
  12713. * @param defines Define statements to be added to the shader.
  12714. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12715. * @param onCompiled Callback that will be called when the shader is compiled.
  12716. * @param onError Callback that will be called if an error occurs during shader compilation.
  12717. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12718. */
  12719. 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);
  12720. /**
  12721. * Unique key for this effect
  12722. */
  12723. readonly key: string;
  12724. /**
  12725. * If the effect has been compiled and prepared.
  12726. * @returns if the effect is compiled and prepared.
  12727. */
  12728. isReady(): boolean;
  12729. /**
  12730. * The engine the effect was initialized with.
  12731. * @returns the engine.
  12732. */
  12733. getEngine(): Engine;
  12734. /**
  12735. * The compiled webGL program for the effect
  12736. * @returns the webGL program.
  12737. */
  12738. getProgram(): WebGLProgram;
  12739. /**
  12740. * The set of names of attribute variables for the shader.
  12741. * @returns An array of attribute names.
  12742. */
  12743. getAttributesNames(): string[];
  12744. /**
  12745. * Returns the attribute at the given index.
  12746. * @param index The index of the attribute.
  12747. * @returns The location of the attribute.
  12748. */
  12749. getAttributeLocation(index: number): number;
  12750. /**
  12751. * Returns the attribute based on the name of the variable.
  12752. * @param name of the attribute to look up.
  12753. * @returns the attribute location.
  12754. */
  12755. getAttributeLocationByName(name: string): number;
  12756. /**
  12757. * The number of attributes.
  12758. * @returns the numnber of attributes.
  12759. */
  12760. getAttributesCount(): number;
  12761. /**
  12762. * Gets the index of a uniform variable.
  12763. * @param uniformName of the uniform to look up.
  12764. * @returns the index.
  12765. */
  12766. getUniformIndex(uniformName: string): number;
  12767. /**
  12768. * Returns the attribute based on the name of the variable.
  12769. * @param uniformName of the uniform to look up.
  12770. * @returns the location of the uniform.
  12771. */
  12772. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12773. /**
  12774. * Returns an array of sampler variable names
  12775. * @returns The array of sampler variable neames.
  12776. */
  12777. getSamplers(): string[];
  12778. /**
  12779. * The error from the last compilation.
  12780. * @returns the error string.
  12781. */
  12782. getCompilationError(): string;
  12783. /**
  12784. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  12785. * @param func The callback to be used.
  12786. */
  12787. executeWhenCompiled(func: (effect: Effect) => void): void;
  12788. /** @hidden */
  12789. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  12790. /** @hidden */
  12791. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  12792. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  12793. private _processShaderConversion(sourceCode, isFragment, callback);
  12794. private _processIncludes(sourceCode, callback);
  12795. private _processPrecision(source);
  12796. /**
  12797. * Recompiles the webGL program
  12798. * @param vertexSourceCode The source code for the vertex shader.
  12799. * @param fragmentSourceCode The source code for the fragment shader.
  12800. * @param onCompiled Callback called when completed.
  12801. * @param onError Callback called on error.
  12802. */
  12803. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  12804. /**
  12805. * Gets the uniform locations of the the specified variable names
  12806. * @param names THe names of the variables to lookup.
  12807. * @returns Array of locations in the same order as variable names.
  12808. */
  12809. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  12810. /**
  12811. * Prepares the effect
  12812. */
  12813. _prepareEffect(): void;
  12814. /**
  12815. * Checks if the effect is supported. (Must be called after compilation)
  12816. */
  12817. readonly isSupported: boolean;
  12818. /**
  12819. * Binds a texture to the engine to be used as output of the shader.
  12820. * @param channel Name of the output variable.
  12821. * @param texture Texture to bind.
  12822. */
  12823. _bindTexture(channel: string, texture: InternalTexture): void;
  12824. /**
  12825. * Sets a texture on the engine to be used in the shader.
  12826. * @param channel Name of the sampler variable.
  12827. * @param texture Texture to set.
  12828. */
  12829. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  12830. /**
  12831. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  12832. * @param channel Name of the sampler variable.
  12833. * @param texture Texture to set.
  12834. */
  12835. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  12836. /**
  12837. * Sets an array of textures on the engine to be used in the shader.
  12838. * @param channel Name of the variable.
  12839. * @param textures Textures to set.
  12840. */
  12841. setTextureArray(channel: string, textures: BaseTexture[]): void;
  12842. /**
  12843. * 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)
  12844. * @param channel Name of the sampler variable.
  12845. * @param postProcess Post process to get the input texture from.
  12846. */
  12847. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  12848. /**
  12849. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  12850. * 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)
  12851. * @param channel Name of the sampler variable.
  12852. * @param postProcess Post process to get the output texture from.
  12853. */
  12854. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  12855. /** @hidden */
  12856. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  12857. /** @hidden */
  12858. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  12859. /** @hidden */
  12860. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  12861. /** @hidden */
  12862. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  12863. /**
  12864. * Binds a buffer to a uniform.
  12865. * @param buffer Buffer to bind.
  12866. * @param name Name of the uniform variable to bind to.
  12867. */
  12868. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  12869. /**
  12870. * Binds block to a uniform.
  12871. * @param blockName Name of the block to bind.
  12872. * @param index Index to bind.
  12873. */
  12874. bindUniformBlock(blockName: string, index: number): void;
  12875. /**
  12876. * Sets an interger value on a uniform variable.
  12877. * @param uniformName Name of the variable.
  12878. * @param value Value to be set.
  12879. * @returns this effect.
  12880. */
  12881. setInt(uniformName: string, value: number): Effect;
  12882. /**
  12883. * Sets an int array on a uniform variable.
  12884. * @param uniformName Name of the variable.
  12885. * @param array array to be set.
  12886. * @returns this effect.
  12887. */
  12888. setIntArray(uniformName: string, array: Int32Array): Effect;
  12889. /**
  12890. * 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)
  12891. * @param uniformName Name of the variable.
  12892. * @param array array to be set.
  12893. * @returns this effect.
  12894. */
  12895. setIntArray2(uniformName: string, array: Int32Array): Effect;
  12896. /**
  12897. * 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)
  12898. * @param uniformName Name of the variable.
  12899. * @param array array to be set.
  12900. * @returns this effect.
  12901. */
  12902. setIntArray3(uniformName: string, array: Int32Array): Effect;
  12903. /**
  12904. * 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)
  12905. * @param uniformName Name of the variable.
  12906. * @param array array to be set.
  12907. * @returns this effect.
  12908. */
  12909. setIntArray4(uniformName: string, array: Int32Array): Effect;
  12910. /**
  12911. * Sets an float array on a uniform variable.
  12912. * @param uniformName Name of the variable.
  12913. * @param array array to be set.
  12914. * @returns this effect.
  12915. */
  12916. setFloatArray(uniformName: string, array: Float32Array): Effect;
  12917. /**
  12918. * 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)
  12919. * @param uniformName Name of the variable.
  12920. * @param array array to be set.
  12921. * @returns this effect.
  12922. */
  12923. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  12924. /**
  12925. * 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)
  12926. * @param uniformName Name of the variable.
  12927. * @param array array to be set.
  12928. * @returns this effect.
  12929. */
  12930. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  12931. /**
  12932. * 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)
  12933. * @param uniformName Name of the variable.
  12934. * @param array array to be set.
  12935. * @returns this effect.
  12936. */
  12937. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  12938. /**
  12939. * Sets an array on a uniform variable.
  12940. * @param uniformName Name of the variable.
  12941. * @param array array to be set.
  12942. * @returns this effect.
  12943. */
  12944. setArray(uniformName: string, array: number[]): Effect;
  12945. /**
  12946. * 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)
  12947. * @param uniformName Name of the variable.
  12948. * @param array array to be set.
  12949. * @returns this effect.
  12950. */
  12951. setArray2(uniformName: string, array: number[]): Effect;
  12952. /**
  12953. * 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)
  12954. * @param uniformName Name of the variable.
  12955. * @param array array to be set.
  12956. * @returns this effect.
  12957. */
  12958. setArray3(uniformName: string, array: number[]): Effect;
  12959. /**
  12960. * 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)
  12961. * @param uniformName Name of the variable.
  12962. * @param array array to be set.
  12963. * @returns this effect.
  12964. */
  12965. setArray4(uniformName: string, array: number[]): Effect;
  12966. /**
  12967. * Sets matrices on a uniform variable.
  12968. * @param uniformName Name of the variable.
  12969. * @param matrices matrices to be set.
  12970. * @returns this effect.
  12971. */
  12972. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  12973. /**
  12974. * Sets matrix on a uniform variable.
  12975. * @param uniformName Name of the variable.
  12976. * @param matrix matrix to be set.
  12977. * @returns this effect.
  12978. */
  12979. setMatrix(uniformName: string, matrix: Matrix): Effect;
  12980. /**
  12981. * 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)
  12982. * @param uniformName Name of the variable.
  12983. * @param matrix matrix to be set.
  12984. * @returns this effect.
  12985. */
  12986. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12987. /**
  12988. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12989. * @param uniformName Name of the variable.
  12990. * @param matrix matrix to be set.
  12991. * @returns this effect.
  12992. */
  12993. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12994. /**
  12995. * Sets a float on a uniform variable.
  12996. * @param uniformName Name of the variable.
  12997. * @param value value to be set.
  12998. * @returns this effect.
  12999. */
  13000. setFloat(uniformName: string, value: number): Effect;
  13001. /**
  13002. * Sets a boolean on a uniform variable.
  13003. * @param uniformName Name of the variable.
  13004. * @param bool value to be set.
  13005. * @returns this effect.
  13006. */
  13007. setBool(uniformName: string, bool: boolean): Effect;
  13008. /**
  13009. * Sets a Vector2 on a uniform variable.
  13010. * @param uniformName Name of the variable.
  13011. * @param vector2 vector2 to be set.
  13012. * @returns this effect.
  13013. */
  13014. setVector2(uniformName: string, vector2: Vector2): Effect;
  13015. /**
  13016. * Sets a float2 on a uniform variable.
  13017. * @param uniformName Name of the variable.
  13018. * @param x First float in float2.
  13019. * @param y Second float in float2.
  13020. * @returns this effect.
  13021. */
  13022. setFloat2(uniformName: string, x: number, y: number): Effect;
  13023. /**
  13024. * Sets a Vector3 on a uniform variable.
  13025. * @param uniformName Name of the variable.
  13026. * @param vector3 Value to be set.
  13027. * @returns this effect.
  13028. */
  13029. setVector3(uniformName: string, vector3: Vector3): Effect;
  13030. /**
  13031. * Sets a float3 on a uniform variable.
  13032. * @param uniformName Name of the variable.
  13033. * @param x First float in float3.
  13034. * @param y Second float in float3.
  13035. * @param z Third float in float3.
  13036. * @returns this effect.
  13037. */
  13038. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13039. /**
  13040. * Sets a Vector4 on a uniform variable.
  13041. * @param uniformName Name of the variable.
  13042. * @param vector4 Value to be set.
  13043. * @returns this effect.
  13044. */
  13045. setVector4(uniformName: string, vector4: Vector4): Effect;
  13046. /**
  13047. * Sets a float4 on a uniform variable.
  13048. * @param uniformName Name of the variable.
  13049. * @param x First float in float4.
  13050. * @param y Second float in float4.
  13051. * @param z Third float in float4.
  13052. * @param w Fourth float in float4.
  13053. * @returns this effect.
  13054. */
  13055. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13056. /**
  13057. * Sets a Color3 on a uniform variable.
  13058. * @param uniformName Name of the variable.
  13059. * @param color3 Value to be set.
  13060. * @returns this effect.
  13061. */
  13062. setColor3(uniformName: string, color3: Color3): Effect;
  13063. /**
  13064. * Sets a Color4 on a uniform variable.
  13065. * @param uniformName Name of the variable.
  13066. * @param color3 Value to be set.
  13067. * @param alpha Alpha value to be set.
  13068. * @returns this effect.
  13069. */
  13070. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13071. /**
  13072. * Sets a Color4 on a uniform variable
  13073. * @param uniformName defines the name of the variable
  13074. * @param color4 defines the value to be set
  13075. * @returns this effect.
  13076. */
  13077. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13078. /**
  13079. * Store of each shader (The can be looked up using effect.key)
  13080. */
  13081. static ShadersStore: {
  13082. [key: string]: string;
  13083. };
  13084. /**
  13085. * Store of each included file for a shader (The can be looked up using effect.key)
  13086. */
  13087. static IncludesShadersStore: {
  13088. [key: string]: string;
  13089. };
  13090. /**
  13091. * Resets the cache of effects.
  13092. */
  13093. static ResetCache(): void;
  13094. }
  13095. }
  13096. declare module BABYLON {
  13097. class FresnelParameters {
  13098. private _isEnabled;
  13099. isEnabled: boolean;
  13100. leftColor: Color3;
  13101. rightColor: Color3;
  13102. bias: number;
  13103. power: number;
  13104. clone(): FresnelParameters;
  13105. serialize(): any;
  13106. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13107. }
  13108. }
  13109. declare module BABYLON {
  13110. /**
  13111. * Interface to follow in your material defines to integrate easily the
  13112. * Image proccessing functions.
  13113. * @hidden
  13114. */
  13115. interface IImageProcessingConfigurationDefines {
  13116. IMAGEPROCESSING: boolean;
  13117. VIGNETTE: boolean;
  13118. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13119. VIGNETTEBLENDMODEOPAQUE: boolean;
  13120. TONEMAPPING: boolean;
  13121. CONTRAST: boolean;
  13122. EXPOSURE: boolean;
  13123. COLORCURVES: boolean;
  13124. COLORGRADING: boolean;
  13125. COLORGRADING3D: boolean;
  13126. SAMPLER3DGREENDEPTH: boolean;
  13127. SAMPLER3DBGRMAP: boolean;
  13128. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13129. }
  13130. /**
  13131. * This groups together the common properties used for image processing either in direct forward pass
  13132. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13133. * or not.
  13134. */
  13135. class ImageProcessingConfiguration {
  13136. /**
  13137. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13138. */
  13139. colorCurves: Nullable<ColorCurves>;
  13140. private _colorCurvesEnabled;
  13141. /**
  13142. * Gets wether the color curves effect is enabled.
  13143. */
  13144. /**
  13145. * Sets wether the color curves effect is enabled.
  13146. */
  13147. colorCurvesEnabled: boolean;
  13148. /**
  13149. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13150. */
  13151. colorGradingTexture: Nullable<BaseTexture>;
  13152. private _colorGradingEnabled;
  13153. /**
  13154. * Gets wether the color grading effect is enabled.
  13155. */
  13156. /**
  13157. * Sets wether the color grading effect is enabled.
  13158. */
  13159. colorGradingEnabled: boolean;
  13160. private _colorGradingWithGreenDepth;
  13161. /**
  13162. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13163. */
  13164. /**
  13165. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13166. */
  13167. colorGradingWithGreenDepth: boolean;
  13168. private _colorGradingBGR;
  13169. /**
  13170. * Gets wether the color grading texture contains BGR values.
  13171. */
  13172. /**
  13173. * Sets wether the color grading texture contains BGR values.
  13174. */
  13175. colorGradingBGR: boolean;
  13176. _exposure: number;
  13177. /**
  13178. * Gets the Exposure used in the effect.
  13179. */
  13180. /**
  13181. * Sets the Exposure used in the effect.
  13182. */
  13183. exposure: number;
  13184. private _toneMappingEnabled;
  13185. /**
  13186. * Gets wether the tone mapping effect is enabled.
  13187. */
  13188. /**
  13189. * Sets wether the tone mapping effect is enabled.
  13190. */
  13191. toneMappingEnabled: boolean;
  13192. protected _contrast: number;
  13193. /**
  13194. * Gets the contrast used in the effect.
  13195. */
  13196. /**
  13197. * Sets the contrast used in the effect.
  13198. */
  13199. contrast: number;
  13200. /**
  13201. * Vignette stretch size.
  13202. */
  13203. vignetteStretch: number;
  13204. /**
  13205. * Vignette centre X Offset.
  13206. */
  13207. vignetteCentreX: number;
  13208. /**
  13209. * Vignette centre Y Offset.
  13210. */
  13211. vignetteCentreY: number;
  13212. /**
  13213. * Vignette weight or intensity of the vignette effect.
  13214. */
  13215. vignetteWeight: number;
  13216. /**
  13217. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13218. * if vignetteEnabled is set to true.
  13219. */
  13220. vignetteColor: Color4;
  13221. /**
  13222. * Camera field of view used by the Vignette effect.
  13223. */
  13224. vignetteCameraFov: number;
  13225. private _vignetteBlendMode;
  13226. /**
  13227. * Gets the vignette blend mode allowing different kind of effect.
  13228. */
  13229. /**
  13230. * Sets the vignette blend mode allowing different kind of effect.
  13231. */
  13232. vignetteBlendMode: number;
  13233. private _vignetteEnabled;
  13234. /**
  13235. * Gets wether the vignette effect is enabled.
  13236. */
  13237. /**
  13238. * Sets wether the vignette effect is enabled.
  13239. */
  13240. vignetteEnabled: boolean;
  13241. private _applyByPostProcess;
  13242. /**
  13243. * Gets wether the image processing is applied through a post process or not.
  13244. */
  13245. /**
  13246. * Sets wether the image processing is applied through a post process or not.
  13247. */
  13248. applyByPostProcess: boolean;
  13249. private _isEnabled;
  13250. /**
  13251. * Gets wether the image processing is enabled or not.
  13252. */
  13253. /**
  13254. * Sets wether the image processing is enabled or not.
  13255. */
  13256. isEnabled: boolean;
  13257. /**
  13258. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13259. */
  13260. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13261. /**
  13262. * Method called each time the image processing information changes requires to recompile the effect.
  13263. */
  13264. protected _updateParameters(): void;
  13265. getClassName(): string;
  13266. /**
  13267. * Prepare the list of uniforms associated with the Image Processing effects.
  13268. * @param uniformsList The list of uniforms used in the effect
  13269. * @param defines the list of defines currently in use
  13270. */
  13271. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13272. /**
  13273. * Prepare the list of samplers associated with the Image Processing effects.
  13274. * @param uniformsList The list of uniforms used in the effect
  13275. * @param defines the list of defines currently in use
  13276. */
  13277. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13278. /**
  13279. * Prepare the list of defines associated to the shader.
  13280. * @param defines the list of defines to complete
  13281. */
  13282. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13283. /**
  13284. * Returns true if all the image processing information are ready.
  13285. */
  13286. isReady(): boolean;
  13287. /**
  13288. * Binds the image processing to the shader.
  13289. * @param effect The effect to bind to
  13290. */
  13291. bind(effect: Effect, aspectRatio?: number): void;
  13292. /**
  13293. * Clones the current image processing instance.
  13294. * @return The cloned image processing
  13295. */
  13296. clone(): ImageProcessingConfiguration;
  13297. /**
  13298. * Serializes the current image processing instance to a json representation.
  13299. * @return a JSON representation
  13300. */
  13301. serialize(): any;
  13302. /**
  13303. * Parses the image processing from a json representation.
  13304. * @param source the JSON source to parse
  13305. * @return The parsed image processing
  13306. */
  13307. static Parse(source: any): ImageProcessingConfiguration;
  13308. private static _VIGNETTEMODE_MULTIPLY;
  13309. private static _VIGNETTEMODE_OPAQUE;
  13310. /**
  13311. * Used to apply the vignette as a mix with the pixel color.
  13312. */
  13313. static readonly VIGNETTEMODE_MULTIPLY: number;
  13314. /**
  13315. * Used to apply the vignette as a replacement of the pixel color.
  13316. */
  13317. static readonly VIGNETTEMODE_OPAQUE: number;
  13318. }
  13319. }
  13320. declare module BABYLON {
  13321. /**
  13322. * Manages the defines for the Material
  13323. */
  13324. class MaterialDefines {
  13325. private _keys;
  13326. private _isDirty;
  13327. /** @hidden */
  13328. _renderId: number;
  13329. /** @hidden */
  13330. _areLightsDirty: boolean;
  13331. /** @hidden */
  13332. _areAttributesDirty: boolean;
  13333. /** @hidden */
  13334. _areTexturesDirty: boolean;
  13335. /** @hidden */
  13336. _areFresnelDirty: boolean;
  13337. /** @hidden */
  13338. _areMiscDirty: boolean;
  13339. /** @hidden */
  13340. _areImageProcessingDirty: boolean;
  13341. /** @hidden */
  13342. _normals: boolean;
  13343. /** @hidden */
  13344. _uvs: boolean;
  13345. /** @hidden */
  13346. _needNormals: boolean;
  13347. /** @hidden */
  13348. _needUVs: boolean;
  13349. /**
  13350. * Specifies if the material needs to be re-calculated
  13351. */
  13352. readonly isDirty: boolean;
  13353. /**
  13354. * Marks the material to indicate that it has been re-calculated
  13355. */
  13356. markAsProcessed(): void;
  13357. /**
  13358. * Marks the material to indicate that it needs to be re-calculated
  13359. */
  13360. markAsUnprocessed(): void;
  13361. /**
  13362. * Marks the material to indicate all of its defines need to be re-calculated
  13363. */
  13364. markAllAsDirty(): void;
  13365. /**
  13366. * Marks the material to indicate that image processing needs to be re-calculated
  13367. */
  13368. markAsImageProcessingDirty(): void;
  13369. /**
  13370. * Marks the material to indicate the lights need to be re-calculated
  13371. */
  13372. markAsLightDirty(): void;
  13373. /**
  13374. * Marks the attribute state as changed
  13375. */
  13376. markAsAttributesDirty(): void;
  13377. /**
  13378. * Marks the texture state as changed
  13379. */
  13380. markAsTexturesDirty(): void;
  13381. /**
  13382. * Marks the fresnel state as changed
  13383. */
  13384. markAsFresnelDirty(): void;
  13385. /**
  13386. * Marks the misc state as changed
  13387. */
  13388. markAsMiscDirty(): void;
  13389. /**
  13390. * Rebuilds the material defines
  13391. */
  13392. rebuild(): void;
  13393. /**
  13394. * Specifies if two material defines are equal
  13395. * @param other - A material define instance to compare to
  13396. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13397. */
  13398. isEqual(other: MaterialDefines): boolean;
  13399. /**
  13400. * Clones this instance's defines to another instance
  13401. * @param other - material defines to clone values to
  13402. */
  13403. cloneTo(other: MaterialDefines): void;
  13404. /**
  13405. * Resets the material define values
  13406. */
  13407. reset(): void;
  13408. /**
  13409. * Converts the material define values to a string
  13410. * @returns - String of material define information
  13411. */
  13412. toString(): string;
  13413. }
  13414. /**
  13415. * Base class for the main features of a material in Babylon.js
  13416. */
  13417. class Material implements IAnimatable {
  13418. private static _TriangleFillMode;
  13419. private static _WireFrameFillMode;
  13420. private static _PointFillMode;
  13421. private static _PointListDrawMode;
  13422. private static _LineListDrawMode;
  13423. private static _LineLoopDrawMode;
  13424. private static _LineStripDrawMode;
  13425. private static _TriangleStripDrawMode;
  13426. private static _TriangleFanDrawMode;
  13427. /**
  13428. * Returns the triangle fill mode
  13429. */
  13430. static readonly TriangleFillMode: number;
  13431. /**
  13432. * Returns the wireframe mode
  13433. */
  13434. static readonly WireFrameFillMode: number;
  13435. /**
  13436. * Returns the point fill mode
  13437. */
  13438. static readonly PointFillMode: number;
  13439. /**
  13440. * Returns the point list draw mode
  13441. */
  13442. static readonly PointListDrawMode: number;
  13443. /**
  13444. * Returns the line list draw mode
  13445. */
  13446. static readonly LineListDrawMode: number;
  13447. /**
  13448. * Returns the line loop draw mode
  13449. */
  13450. static readonly LineLoopDrawMode: number;
  13451. /**
  13452. * Returns the line strip draw mode
  13453. */
  13454. static readonly LineStripDrawMode: number;
  13455. /**
  13456. * Returns the triangle strip draw mode
  13457. */
  13458. static readonly TriangleStripDrawMode: number;
  13459. /**
  13460. * Returns the triangle fan draw mode
  13461. */
  13462. static readonly TriangleFanDrawMode: number;
  13463. /**
  13464. * Stores the clock-wise side orientation
  13465. */
  13466. private static _ClockWiseSideOrientation;
  13467. /**
  13468. * Stores the counter clock-wise side orientation
  13469. */
  13470. private static _CounterClockWiseSideOrientation;
  13471. /**
  13472. * Returns the clock-wise side orientation
  13473. */
  13474. static readonly ClockWiseSideOrientation: number;
  13475. /**
  13476. * Returns the counter clock-wise side orientation
  13477. */
  13478. static readonly CounterClockWiseSideOrientation: number;
  13479. /**
  13480. * The dirty texture flag value
  13481. */
  13482. private static _TextureDirtyFlag;
  13483. /**
  13484. * The dirty light flag value
  13485. */
  13486. private static _LightDirtyFlag;
  13487. /**
  13488. * The dirty fresnel flag value
  13489. */
  13490. private static _FresnelDirtyFlag;
  13491. /**
  13492. * The dirty attribute flag value
  13493. */
  13494. private static _AttributesDirtyFlag;
  13495. /**
  13496. * The dirty misc flag value
  13497. */
  13498. private static _MiscDirtyFlag;
  13499. /**
  13500. * Returns the dirty texture flag value
  13501. */
  13502. static readonly TextureDirtyFlag: number;
  13503. /**
  13504. * Returns the dirty light flag value
  13505. */
  13506. static readonly LightDirtyFlag: number;
  13507. /**
  13508. * Returns the dirty fresnel flag value
  13509. */
  13510. static readonly FresnelDirtyFlag: number;
  13511. /**
  13512. * Returns the dirty attributes flag value
  13513. */
  13514. static readonly AttributesDirtyFlag: number;
  13515. /**
  13516. * Returns the dirty misc flag value
  13517. */
  13518. static readonly MiscDirtyFlag: number;
  13519. /**
  13520. * The ID of the material
  13521. */
  13522. id: string;
  13523. /**
  13524. * Gets or sets the unique id of the material
  13525. */
  13526. uniqueId: number;
  13527. /**
  13528. * The name of the material
  13529. */
  13530. name: string;
  13531. /**
  13532. * Specifies if the ready state should be checked on each call
  13533. */
  13534. checkReadyOnEveryCall: boolean;
  13535. /**
  13536. * Specifies if the ready state should be checked once
  13537. */
  13538. checkReadyOnlyOnce: boolean;
  13539. /**
  13540. * The state of the material
  13541. */
  13542. state: string;
  13543. /**
  13544. * The alpha value of the material
  13545. */
  13546. protected _alpha: number;
  13547. /**
  13548. * Gets the alpha value of the material
  13549. */
  13550. /**
  13551. * Sets the alpha value of the material
  13552. */
  13553. alpha: number;
  13554. /**
  13555. * Specifies if back face culling is enabled
  13556. */
  13557. protected _backFaceCulling: boolean;
  13558. /**
  13559. * Gets the back-face culling state
  13560. */
  13561. /**
  13562. * Sets the back-face culling state
  13563. */
  13564. backFaceCulling: boolean;
  13565. /**
  13566. * Stores the value for side orientation
  13567. */
  13568. sideOrientation: number;
  13569. /**
  13570. * Callback triggered when the material is compiled
  13571. */
  13572. onCompiled: (effect: Effect) => void;
  13573. /**
  13574. * Callback triggered when an error occurs
  13575. */
  13576. onError: (effect: Effect, errors: string) => void;
  13577. /**
  13578. * Callback triggered to get the render target textures
  13579. */
  13580. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13581. /**
  13582. * Specifies if the material should be serialized
  13583. */
  13584. doNotSerialize: boolean;
  13585. /**
  13586. * Specifies if the effect should be stored on sub meshes
  13587. */
  13588. storeEffectOnSubMeshes: boolean;
  13589. /**
  13590. * Stores the animations for the material
  13591. */
  13592. animations: Array<Animation>;
  13593. /**
  13594. * An event triggered when the material is disposed
  13595. */
  13596. onDisposeObservable: Observable<Material>;
  13597. /**
  13598. * An observer which watches for dispose events
  13599. */
  13600. private _onDisposeObserver;
  13601. /**
  13602. * Called during a dispose event
  13603. */
  13604. onDispose: () => void;
  13605. /**
  13606. * An event triggered when the material is bound
  13607. */
  13608. onBindObservable: Observable<AbstractMesh>;
  13609. /**
  13610. * An observer which watches for bind events
  13611. */
  13612. private _onBindObserver;
  13613. /**
  13614. * Called during a bind event
  13615. */
  13616. onBind: (Mesh: AbstractMesh) => void;
  13617. /**
  13618. * An event triggered when the material is unbound
  13619. */
  13620. onUnBindObservable: Observable<Material>;
  13621. /**
  13622. * Stores the value of the alpha mode
  13623. */
  13624. private _alphaMode;
  13625. /**
  13626. * Gets the value of the alpha mode
  13627. */
  13628. /**
  13629. * Sets the value of the alpha mode.
  13630. *
  13631. * | Value | Type | Description |
  13632. * | --- | --- | --- |
  13633. * | 0 | ALPHA_DISABLE | |
  13634. * | 1 | ALPHA_ADD | |
  13635. * | 2 | ALPHA_COMBINE | |
  13636. * | 3 | ALPHA_SUBTRACT | |
  13637. * | 4 | ALPHA_MULTIPLY | |
  13638. * | 5 | ALPHA_MAXIMIZED | |
  13639. * | 6 | ALPHA_ONEONE | |
  13640. * | 7 | ALPHA_PREMULTIPLIED | |
  13641. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13642. * | 9 | ALPHA_INTERPOLATE | |
  13643. * | 10 | ALPHA_SCREENMODE | |
  13644. *
  13645. */
  13646. alphaMode: number;
  13647. /**
  13648. * Stores the state of the need depth pre-pass value
  13649. */
  13650. private _needDepthPrePass;
  13651. /**
  13652. * Gets the depth pre-pass value
  13653. */
  13654. /**
  13655. * Sets the need depth pre-pass value
  13656. */
  13657. needDepthPrePass: boolean;
  13658. /**
  13659. * Specifies if depth writing should be disabled
  13660. */
  13661. disableDepthWrite: boolean;
  13662. /**
  13663. * Specifies if depth writing should be forced
  13664. */
  13665. forceDepthWrite: boolean;
  13666. /**
  13667. * Specifies if there should be a separate pass for culling
  13668. */
  13669. separateCullingPass: boolean;
  13670. /**
  13671. * Stores the state specifing if fog should be enabled
  13672. */
  13673. private _fogEnabled;
  13674. /**
  13675. * Gets the value of the fog enabled state
  13676. */
  13677. /**
  13678. * Sets the state for enabling fog
  13679. */
  13680. fogEnabled: boolean;
  13681. /**
  13682. * Stores the size of points
  13683. */
  13684. pointSize: number;
  13685. /**
  13686. * Stores the z offset value
  13687. */
  13688. zOffset: number;
  13689. /**
  13690. * Gets a value specifying if wireframe mode is enabled
  13691. */
  13692. /**
  13693. * Sets the state of wireframe mode
  13694. */
  13695. wireframe: boolean;
  13696. /**
  13697. * Gets the value specifying if point clouds are enabled
  13698. */
  13699. /**
  13700. * Sets the state of point cloud mode
  13701. */
  13702. pointsCloud: boolean;
  13703. /**
  13704. * Gets the material fill mode
  13705. */
  13706. /**
  13707. * Sets the material fill mode
  13708. */
  13709. fillMode: number;
  13710. /**
  13711. * Stores the effects for the material
  13712. */
  13713. _effect: Nullable<Effect>;
  13714. /**
  13715. * Specifies if the material was previously ready
  13716. */
  13717. _wasPreviouslyReady: boolean;
  13718. /**
  13719. * Specifies if uniform buffers should be used
  13720. */
  13721. private _useUBO;
  13722. /**
  13723. * Stores a reference to the scene
  13724. */
  13725. private _scene;
  13726. /**
  13727. * Stores the fill mode state
  13728. */
  13729. private _fillMode;
  13730. /**
  13731. * Specifies if the depth write state should be cached
  13732. */
  13733. private _cachedDepthWriteState;
  13734. /**
  13735. * Stores the uniform buffer
  13736. */
  13737. protected _uniformBuffer: UniformBuffer;
  13738. /**
  13739. * Creates a material instance
  13740. * @param name defines the name of the material
  13741. * @param scene defines the scene to reference
  13742. * @param doNotAdd specifies if the material should be added to the scene
  13743. */
  13744. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13745. /**
  13746. * Returns a string representation of the current material
  13747. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13748. * @returns a string with material information
  13749. */
  13750. toString(fullDetails?: boolean): string;
  13751. /**
  13752. * Gets the class name of the material
  13753. * @returns a string with the class name of the material
  13754. */
  13755. getClassName(): string;
  13756. /**
  13757. * Specifies if updates for the material been locked
  13758. */
  13759. readonly isFrozen: boolean;
  13760. /**
  13761. * Locks updates for the material
  13762. */
  13763. freeze(): void;
  13764. /**
  13765. * Unlocks updates for the material
  13766. */
  13767. unfreeze(): void;
  13768. /**
  13769. * Specifies if the material is ready to be used
  13770. * @param mesh defines the mesh to check
  13771. * @param useInstances specifies if instances should be used
  13772. * @returns a boolean indicating if the material is ready to be used
  13773. */
  13774. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13775. /**
  13776. * Specifies that the submesh is ready to be used
  13777. * @param mesh defines the mesh to check
  13778. * @param subMesh defines which submesh to check
  13779. * @param useInstances specifies that instances should be used
  13780. * @returns a boolean indicating that the submesh is ready or not
  13781. */
  13782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13783. /**
  13784. * Returns the material effect
  13785. * @returns the effect associated with the material
  13786. */
  13787. getEffect(): Nullable<Effect>;
  13788. /**
  13789. * Returns the current scene
  13790. * @returns a Scene
  13791. */
  13792. getScene(): Scene;
  13793. /**
  13794. * Specifies if the material will require alpha blending
  13795. * @returns a boolean specifying if alpha blending is needed
  13796. */
  13797. needAlphaBlending(): boolean;
  13798. /**
  13799. * Specifies if the mesh will require alpha blending
  13800. * @param mesh defines the mesh to check
  13801. * @returns a boolean specifying if alpha blending is needed for the mesh
  13802. */
  13803. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  13804. /**
  13805. * Specifies if this material should be rendered in alpha test mode
  13806. * @returns a boolean specifying if an alpha test is needed.
  13807. */
  13808. needAlphaTesting(): boolean;
  13809. /**
  13810. * Gets the texture used for the alpha test
  13811. * @returns the texture to use for alpha testing
  13812. */
  13813. getAlphaTestTexture(): Nullable<BaseTexture>;
  13814. /**
  13815. * Marks the material to indicate that it needs to be re-calculated
  13816. */
  13817. markDirty(): void;
  13818. /** @hidden */
  13819. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  13820. /**
  13821. * Binds the material to the mesh
  13822. * @param world defines the world transformation matrix
  13823. * @param mesh defines the mesh to bind the material to
  13824. */
  13825. bind(world: Matrix, mesh?: Mesh): void;
  13826. /**
  13827. * Binds the submesh to the material
  13828. * @param world defines the world transformation matrix
  13829. * @param mesh defines the mesh containing the submesh
  13830. * @param subMesh defines the submesh to bind the material to
  13831. */
  13832. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13833. /**
  13834. * Binds the world matrix to the material
  13835. * @param world defines the world transformation matrix
  13836. */
  13837. bindOnlyWorldMatrix(world: Matrix): void;
  13838. /**
  13839. * Binds the scene's uniform buffer to the effect.
  13840. * @param effect defines the effect to bind to the scene uniform buffer
  13841. * @param sceneUbo defines the uniform buffer storing scene data
  13842. */
  13843. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  13844. /**
  13845. * Binds the view matrix to the effect
  13846. * @param effect defines the effect to bind the view matrix to
  13847. */
  13848. bindView(effect: Effect): void;
  13849. /**
  13850. * Binds the view projection matrix to the effect
  13851. * @param effect defines the effect to bind the view projection matrix to
  13852. */
  13853. bindViewProjection(effect: Effect): void;
  13854. /**
  13855. * Specifies if material alpha testing should be turned on for the mesh
  13856. * @param mesh defines the mesh to check
  13857. */
  13858. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  13859. /**
  13860. * Processes to execute after binding the material to a mesh
  13861. * @param mesh defines the rendered mesh
  13862. */
  13863. protected _afterBind(mesh?: Mesh): void;
  13864. /**
  13865. * Unbinds the material from the mesh
  13866. */
  13867. unbind(): void;
  13868. /**
  13869. * Gets the active textures from the material
  13870. * @returns an array of textures
  13871. */
  13872. getActiveTextures(): BaseTexture[];
  13873. /**
  13874. * Specifies if the material uses a texture
  13875. * @param texture defines the texture to check against the material
  13876. * @returns a boolean specifying if the material uses the texture
  13877. */
  13878. hasTexture(texture: BaseTexture): boolean;
  13879. /**
  13880. * Makes a duplicate of the material, and gives it a new name
  13881. * @param name defines the new name for the duplicated material
  13882. * @returns the cloned material
  13883. */
  13884. clone(name: string): Nullable<Material>;
  13885. /**
  13886. * Gets the meshes bound to the material
  13887. * @returns an array of meshes bound to the material
  13888. */
  13889. getBindedMeshes(): AbstractMesh[];
  13890. /**
  13891. * Force shader compilation
  13892. * @param mesh defines the mesh associated with this material
  13893. * @param onCompiled defines a function to execute once the material is compiled
  13894. * @param options defines the options to configure the compilation
  13895. */
  13896. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  13897. clipPlane: boolean;
  13898. }>): void;
  13899. /**
  13900. * Force shader compilation
  13901. * @param mesh defines the mesh that will use this material
  13902. * @param options defines additional options for compiling the shaders
  13903. * @returns a promise that resolves when the compilation completes
  13904. */
  13905. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  13906. clipPlane: boolean;
  13907. }>): Promise<void>;
  13908. /**
  13909. * Marks a define in the material to indicate that it needs to be re-computed
  13910. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  13911. */
  13912. markAsDirty(flag: number): void;
  13913. /**
  13914. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  13915. * @param func defines a function which checks material defines against the submeshes
  13916. */
  13917. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  13918. /**
  13919. * Indicates that image processing needs to be re-calculated for all submeshes
  13920. */
  13921. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  13922. /**
  13923. * Indicates that textures need to be re-calculated for all submeshes
  13924. */
  13925. protected _markAllSubMeshesAsTexturesDirty(): void;
  13926. /**
  13927. * Indicates that fresnel needs to be re-calculated for all submeshes
  13928. */
  13929. protected _markAllSubMeshesAsFresnelDirty(): void;
  13930. /**
  13931. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  13932. */
  13933. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  13934. /**
  13935. * Indicates that lights need to be re-calculated for all submeshes
  13936. */
  13937. protected _markAllSubMeshesAsLightsDirty(): void;
  13938. /**
  13939. * Indicates that attributes need to be re-calculated for all submeshes
  13940. */
  13941. protected _markAllSubMeshesAsAttributesDirty(): void;
  13942. /**
  13943. * Indicates that misc needs to be re-calculated for all submeshes
  13944. */
  13945. protected _markAllSubMeshesAsMiscDirty(): void;
  13946. /**
  13947. * Indicates that textures and misc need to be re-calculated for all submeshes
  13948. */
  13949. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  13950. /**
  13951. * Disposes the material
  13952. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  13953. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  13954. */
  13955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13956. /**
  13957. * Serializes this material
  13958. * @returns the serialized material object
  13959. */
  13960. serialize(): any;
  13961. /**
  13962. * Creates a MultiMaterial from parsed MultiMaterial data.
  13963. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  13964. * @param scene defines the hosting scene
  13965. * @returns a new MultiMaterial
  13966. */
  13967. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  13968. /**
  13969. * Creates a material from parsed material data
  13970. * @param parsedMaterial defines parsed material data
  13971. * @param scene defines the hosting scene
  13972. * @param rootUrl defines the root URL to use to load textures
  13973. * @returns a new material
  13974. */
  13975. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  13976. }
  13977. }
  13978. declare module BABYLON {
  13979. /**
  13980. * "Static Class" containing the most commonly used helper while dealing with material for
  13981. * rendering purpose.
  13982. *
  13983. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  13984. *
  13985. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  13986. */
  13987. class MaterialHelper {
  13988. /**
  13989. * Bind the current view position to an effect.
  13990. * @param effect The effect to be bound
  13991. * @param scene The scene the eyes position is used from
  13992. */
  13993. static BindEyePosition(effect: Effect, scene: Scene): void;
  13994. /**
  13995. * Helps preparing the defines values about the UVs in used in the effect.
  13996. * UVs are shared as much as we can accross chanels in the shaders.
  13997. * @param texture The texture we are preparing the UVs for
  13998. * @param defines The defines to update
  13999. * @param key The chanel key "diffuse", "specular"... used in the shader
  14000. */
  14001. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14002. /**
  14003. * Binds a texture matrix value to its corrsponding uniform
  14004. * @param texture The texture to bind the matrix for
  14005. * @param uniformBuffer The uniform buffer receivin the data
  14006. * @param key The chanel key "diffuse", "specular"... used in the shader
  14007. */
  14008. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14009. /**
  14010. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14011. * @param mesh defines the current mesh
  14012. * @param scene defines the current scene
  14013. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14014. * @param pointsCloud defines if point cloud rendering has to be turned on
  14015. * @param fogEnabled defines if fog has to be turned on
  14016. * @param alphaTest defines if alpha testing has to be turned on
  14017. * @param defines defines the current list of defines
  14018. */
  14019. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14020. /**
  14021. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14022. * @param scene defines the current scene
  14023. * @param engine defines the current engine
  14024. * @param defines specifies the list of active defines
  14025. * @param useInstances defines if instances have to be turned on
  14026. * @param useClipPlane defines if clip plane have to be turned on
  14027. */
  14028. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14029. /**
  14030. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14031. * @param mesh The mesh containing the geometry data we will draw
  14032. * @param defines The defines to update
  14033. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14034. * @param useBones Precise whether bones should be used or not (override mesh info)
  14035. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14036. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14037. * @returns false if defines are considered not dirty and have not been checked
  14038. */
  14039. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14040. /**
  14041. * Prepares the defines related to the light information passed in parameter
  14042. * @param scene The scene we are intending to draw
  14043. * @param mesh The mesh the effect is compiling for
  14044. * @param defines The defines to update
  14045. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14046. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14047. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14048. * @returns true if normals will be required for the rest of the effect
  14049. */
  14050. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14051. /**
  14052. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14053. * that won t be acctive due to defines being turned off.
  14054. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14055. * @param samplersList The samplers list
  14056. * @param defines The defines helping in the list generation
  14057. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14058. */
  14059. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14060. /**
  14061. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14062. * @param defines The defines to update while falling back
  14063. * @param fallbacks The authorized effect fallbacks
  14064. * @param maxSimultaneousLights The maximum number of lights allowed
  14065. * @param rank the current rank of the Effect
  14066. * @returns The newly affected rank
  14067. */
  14068. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14069. /**
  14070. * Prepares the list of attributes required for morph targets according to the effect defines.
  14071. * @param attribs The current list of supported attribs
  14072. * @param mesh The mesh to prepare the morph targets attributes for
  14073. * @param defines The current Defines of the effect
  14074. */
  14075. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14076. /**
  14077. * Prepares the list of attributes required for bones according to the effect defines.
  14078. * @param attribs The current list of supported attribs
  14079. * @param mesh The mesh to prepare the bones attributes for
  14080. * @param defines The current Defines of the effect
  14081. * @param fallbacks The current efffect fallback strategy
  14082. */
  14083. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14084. /**
  14085. * Prepares the list of attributes required for instances according to the effect defines.
  14086. * @param attribs The current list of supported attribs
  14087. * @param defines The current Defines of the effect
  14088. */
  14089. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14090. /**
  14091. * Binds the light shadow information to the effect for the given mesh.
  14092. * @param light The light containing the generator
  14093. * @param scene The scene the lights belongs to
  14094. * @param mesh The mesh we are binding the information to render
  14095. * @param lightIndex The light index in the effect used to render the mesh
  14096. * @param effect The effect we are binding the data to
  14097. */
  14098. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14099. /**
  14100. * Binds the light information to the effect.
  14101. * @param light The light containing the generator
  14102. * @param effect The effect we are binding the data to
  14103. * @param lightIndex The light index in the effect used to render
  14104. */
  14105. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14106. /**
  14107. * Binds the lights information from the scene to the effect for the given mesh.
  14108. * @param scene The scene the lights belongs to
  14109. * @param mesh The mesh we are binding the information to render
  14110. * @param effect The effect we are binding the data to
  14111. * @param defines The generated defines for the effect
  14112. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14113. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14114. */
  14115. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14116. /**
  14117. * Binds the fog information from the scene to the effect for the given mesh.
  14118. * @param scene The scene the lights belongs to
  14119. * @param mesh The mesh we are binding the information to render
  14120. * @param effect The effect we are binding the data to
  14121. */
  14122. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14123. /**
  14124. * Binds the bones information from the mesh to the effect.
  14125. * @param mesh The mesh we are binding the information to render
  14126. * @param effect The effect we are binding the data to
  14127. */
  14128. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14129. /**
  14130. * Binds the morph targets information from the mesh to the effect.
  14131. * @param abstractMesh The mesh we are binding the information to render
  14132. * @param effect The effect we are binding the data to
  14133. */
  14134. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14135. /**
  14136. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14137. * @param defines The generated defines used in the effect
  14138. * @param effect The effect we are binding the data to
  14139. * @param scene The scene we are willing to render with logarithmic scale for
  14140. */
  14141. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14142. /**
  14143. * Binds the clip plane information from the scene to the effect.
  14144. * @param scene The scene the clip plane information are extracted from
  14145. * @param effect The effect we are binding the data to
  14146. */
  14147. static BindClipPlane(effect: Effect, scene: Scene): void;
  14148. }
  14149. }
  14150. declare module BABYLON {
  14151. class MultiMaterial extends Material {
  14152. private _subMaterials;
  14153. subMaterials: Nullable<Material>[];
  14154. constructor(name: string, scene: Scene);
  14155. private _hookArray(array);
  14156. getSubMaterial(index: number): Nullable<Material>;
  14157. getActiveTextures(): BaseTexture[];
  14158. getClassName(): string;
  14159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14160. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14161. serialize(): any;
  14162. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14163. }
  14164. }
  14165. declare module BABYLON {
  14166. class PushMaterial extends Material {
  14167. protected _activeEffect: Effect;
  14168. protected _normalMatrix: Matrix;
  14169. constructor(name: string, scene: Scene);
  14170. getEffect(): Effect;
  14171. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14172. /**
  14173. * Binds the given world matrix to the active effect
  14174. *
  14175. * @param world the matrix to bind
  14176. */
  14177. bindOnlyWorldMatrix(world: Matrix): void;
  14178. /**
  14179. * Binds the given normal matrix to the active effect
  14180. *
  14181. * @param normalMatrix the matrix to bind
  14182. */
  14183. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14184. bind(world: Matrix, mesh?: Mesh): void;
  14185. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14186. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14187. }
  14188. }
  14189. declare module BABYLON {
  14190. class ShaderMaterial extends Material {
  14191. private _shaderPath;
  14192. private _options;
  14193. private _textures;
  14194. private _textureArrays;
  14195. private _floats;
  14196. private _ints;
  14197. private _floatsArrays;
  14198. private _colors3;
  14199. private _colors3Arrays;
  14200. private _colors4;
  14201. private _vectors2;
  14202. private _vectors3;
  14203. private _vectors4;
  14204. private _matrices;
  14205. private _matrices3x3;
  14206. private _matrices2x2;
  14207. private _vectors2Arrays;
  14208. private _vectors3Arrays;
  14209. private _cachedWorldViewMatrix;
  14210. private _renderId;
  14211. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14212. getClassName(): string;
  14213. needAlphaBlending(): boolean;
  14214. needAlphaTesting(): boolean;
  14215. private _checkUniform(uniformName);
  14216. setTexture(name: string, texture: Texture): ShaderMaterial;
  14217. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14218. setFloat(name: string, value: number): ShaderMaterial;
  14219. setInt(name: string, value: number): ShaderMaterial;
  14220. setFloats(name: string, value: number[]): ShaderMaterial;
  14221. setColor3(name: string, value: Color3): ShaderMaterial;
  14222. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14223. setColor4(name: string, value: Color4): ShaderMaterial;
  14224. setVector2(name: string, value: Vector2): ShaderMaterial;
  14225. setVector3(name: string, value: Vector3): ShaderMaterial;
  14226. setVector4(name: string, value: Vector4): ShaderMaterial;
  14227. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14228. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14229. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14230. setArray2(name: string, value: number[]): ShaderMaterial;
  14231. setArray3(name: string, value: number[]): ShaderMaterial;
  14232. private _checkCache(scene, mesh?, useInstances?);
  14233. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14234. bindOnlyWorldMatrix(world: Matrix): void;
  14235. bind(world: Matrix, mesh?: Mesh): void;
  14236. getActiveTextures(): BaseTexture[];
  14237. hasTexture(texture: BaseTexture): boolean;
  14238. clone(name: string): ShaderMaterial;
  14239. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14240. serialize(): any;
  14241. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14242. }
  14243. }
  14244. declare module BABYLON {
  14245. /** @hidden */
  14246. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14247. MAINUV1: boolean;
  14248. MAINUV2: boolean;
  14249. DIFFUSE: boolean;
  14250. DIFFUSEDIRECTUV: number;
  14251. AMBIENT: boolean;
  14252. AMBIENTDIRECTUV: number;
  14253. OPACITY: boolean;
  14254. OPACITYDIRECTUV: number;
  14255. OPACITYRGB: boolean;
  14256. REFLECTION: boolean;
  14257. EMISSIVE: boolean;
  14258. EMISSIVEDIRECTUV: number;
  14259. SPECULAR: boolean;
  14260. SPECULARDIRECTUV: number;
  14261. BUMP: boolean;
  14262. BUMPDIRECTUV: number;
  14263. PARALLAX: boolean;
  14264. PARALLAXOCCLUSION: boolean;
  14265. SPECULAROVERALPHA: boolean;
  14266. CLIPPLANE: boolean;
  14267. ALPHATEST: boolean;
  14268. DEPTHPREPASS: boolean;
  14269. ALPHAFROMDIFFUSE: boolean;
  14270. POINTSIZE: boolean;
  14271. FOG: boolean;
  14272. SPECULARTERM: boolean;
  14273. DIFFUSEFRESNEL: boolean;
  14274. OPACITYFRESNEL: boolean;
  14275. REFLECTIONFRESNEL: boolean;
  14276. REFRACTIONFRESNEL: boolean;
  14277. EMISSIVEFRESNEL: boolean;
  14278. FRESNEL: boolean;
  14279. NORMAL: boolean;
  14280. UV1: boolean;
  14281. UV2: boolean;
  14282. VERTEXCOLOR: boolean;
  14283. VERTEXALPHA: boolean;
  14284. NUM_BONE_INFLUENCERS: number;
  14285. BonesPerMesh: number;
  14286. INSTANCES: boolean;
  14287. GLOSSINESS: boolean;
  14288. ROUGHNESS: boolean;
  14289. EMISSIVEASILLUMINATION: boolean;
  14290. LINKEMISSIVEWITHDIFFUSE: boolean;
  14291. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14292. LIGHTMAP: boolean;
  14293. LIGHTMAPDIRECTUV: number;
  14294. OBJECTSPACE_NORMALMAP: boolean;
  14295. USELIGHTMAPASSHADOWMAP: boolean;
  14296. REFLECTIONMAP_3D: boolean;
  14297. REFLECTIONMAP_SPHERICAL: boolean;
  14298. REFLECTIONMAP_PLANAR: boolean;
  14299. REFLECTIONMAP_CUBIC: boolean;
  14300. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14301. REFLECTIONMAP_PROJECTION: boolean;
  14302. REFLECTIONMAP_SKYBOX: boolean;
  14303. REFLECTIONMAP_EXPLICIT: boolean;
  14304. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14305. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14306. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14307. INVERTCUBICMAP: boolean;
  14308. LOGARITHMICDEPTH: boolean;
  14309. REFRACTION: boolean;
  14310. REFRACTIONMAP_3D: boolean;
  14311. REFLECTIONOVERALPHA: boolean;
  14312. TWOSIDEDLIGHTING: boolean;
  14313. SHADOWFLOAT: boolean;
  14314. MORPHTARGETS: boolean;
  14315. MORPHTARGETS_NORMAL: boolean;
  14316. MORPHTARGETS_TANGENT: boolean;
  14317. NUM_MORPH_INFLUENCERS: number;
  14318. NONUNIFORMSCALING: boolean;
  14319. PREMULTIPLYALPHA: boolean;
  14320. IMAGEPROCESSING: boolean;
  14321. VIGNETTE: boolean;
  14322. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14323. VIGNETTEBLENDMODEOPAQUE: boolean;
  14324. TONEMAPPING: boolean;
  14325. CONTRAST: boolean;
  14326. COLORCURVES: boolean;
  14327. COLORGRADING: boolean;
  14328. COLORGRADING3D: boolean;
  14329. SAMPLER3DGREENDEPTH: boolean;
  14330. SAMPLER3DBGRMAP: boolean;
  14331. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14332. /**
  14333. * If the reflection texture on this material is in linear color space
  14334. * @hidden
  14335. */
  14336. IS_REFLECTION_LINEAR: boolean;
  14337. /**
  14338. * If the refraction texture on this material is in linear color space
  14339. * @hidden
  14340. */
  14341. IS_REFRACTION_LINEAR: boolean;
  14342. EXPOSURE: boolean;
  14343. constructor();
  14344. setReflectionMode(modeToEnable: string): void;
  14345. }
  14346. class StandardMaterial extends PushMaterial {
  14347. private _diffuseTexture;
  14348. diffuseTexture: Nullable<BaseTexture>;
  14349. private _ambientTexture;
  14350. ambientTexture: Nullable<BaseTexture>;
  14351. private _opacityTexture;
  14352. opacityTexture: Nullable<BaseTexture>;
  14353. private _reflectionTexture;
  14354. reflectionTexture: Nullable<BaseTexture>;
  14355. private _emissiveTexture;
  14356. emissiveTexture: Nullable<BaseTexture>;
  14357. private _specularTexture;
  14358. specularTexture: Nullable<BaseTexture>;
  14359. private _bumpTexture;
  14360. bumpTexture: Nullable<BaseTexture>;
  14361. private _lightmapTexture;
  14362. lightmapTexture: Nullable<BaseTexture>;
  14363. private _refractionTexture;
  14364. refractionTexture: Nullable<BaseTexture>;
  14365. ambientColor: Color3;
  14366. diffuseColor: Color3;
  14367. specularColor: Color3;
  14368. emissiveColor: Color3;
  14369. specularPower: number;
  14370. private _useAlphaFromDiffuseTexture;
  14371. useAlphaFromDiffuseTexture: boolean;
  14372. private _useEmissiveAsIllumination;
  14373. useEmissiveAsIllumination: boolean;
  14374. private _linkEmissiveWithDiffuse;
  14375. linkEmissiveWithDiffuse: boolean;
  14376. private _useSpecularOverAlpha;
  14377. useSpecularOverAlpha: boolean;
  14378. private _useReflectionOverAlpha;
  14379. useReflectionOverAlpha: boolean;
  14380. private _disableLighting;
  14381. disableLighting: boolean;
  14382. private _useObjectSpaceNormalMap;
  14383. /**
  14384. * Allows using an object space normal map (instead of tangent space).
  14385. */
  14386. useObjectSpaceNormalMap: boolean;
  14387. private _useParallax;
  14388. useParallax: boolean;
  14389. private _useParallaxOcclusion;
  14390. useParallaxOcclusion: boolean;
  14391. parallaxScaleBias: number;
  14392. private _roughness;
  14393. roughness: number;
  14394. indexOfRefraction: number;
  14395. invertRefractionY: boolean;
  14396. /**
  14397. * Defines the alpha limits in alpha test mode
  14398. */
  14399. alphaCutOff: number;
  14400. private _useLightmapAsShadowmap;
  14401. useLightmapAsShadowmap: boolean;
  14402. private _diffuseFresnelParameters;
  14403. diffuseFresnelParameters: FresnelParameters;
  14404. private _opacityFresnelParameters;
  14405. opacityFresnelParameters: FresnelParameters;
  14406. private _reflectionFresnelParameters;
  14407. reflectionFresnelParameters: FresnelParameters;
  14408. private _refractionFresnelParameters;
  14409. refractionFresnelParameters: FresnelParameters;
  14410. private _emissiveFresnelParameters;
  14411. emissiveFresnelParameters: FresnelParameters;
  14412. private _useReflectionFresnelFromSpecular;
  14413. useReflectionFresnelFromSpecular: boolean;
  14414. private _useGlossinessFromSpecularMapAlpha;
  14415. useGlossinessFromSpecularMapAlpha: boolean;
  14416. private _maxSimultaneousLights;
  14417. maxSimultaneousLights: number;
  14418. /**
  14419. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14420. */
  14421. private _invertNormalMapX;
  14422. invertNormalMapX: boolean;
  14423. /**
  14424. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14425. */
  14426. private _invertNormalMapY;
  14427. invertNormalMapY: boolean;
  14428. /**
  14429. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14430. */
  14431. private _twoSidedLighting;
  14432. twoSidedLighting: boolean;
  14433. /**
  14434. * Default configuration related to image processing available in the standard Material.
  14435. */
  14436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14437. /**
  14438. * Gets the image processing configuration used either in this material.
  14439. */
  14440. /**
  14441. * Sets the Default image processing configuration used either in the this material.
  14442. *
  14443. * If sets to null, the scene one is in use.
  14444. */
  14445. imageProcessingConfiguration: ImageProcessingConfiguration;
  14446. /**
  14447. * Keep track of the image processing observer to allow dispose and replace.
  14448. */
  14449. private _imageProcessingObserver;
  14450. /**
  14451. * Attaches a new image processing configuration to the Standard Material.
  14452. * @param configuration
  14453. */
  14454. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14455. /**
  14456. * Gets wether the color curves effect is enabled.
  14457. */
  14458. /**
  14459. * Sets wether the color curves effect is enabled.
  14460. */
  14461. cameraColorCurvesEnabled: boolean;
  14462. /**
  14463. * Gets wether the color grading effect is enabled.
  14464. */
  14465. /**
  14466. * Gets wether the color grading effect is enabled.
  14467. */
  14468. cameraColorGradingEnabled: boolean;
  14469. /**
  14470. * Gets wether tonemapping is enabled or not.
  14471. */
  14472. /**
  14473. * Sets wether tonemapping is enabled or not
  14474. */
  14475. cameraToneMappingEnabled: boolean;
  14476. /**
  14477. * The camera exposure used on this material.
  14478. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14479. * This corresponds to a photographic exposure.
  14480. */
  14481. /**
  14482. * The camera exposure used on this material.
  14483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14484. * This corresponds to a photographic exposure.
  14485. */
  14486. cameraExposure: number;
  14487. /**
  14488. * Gets The camera contrast used on this material.
  14489. */
  14490. /**
  14491. * Sets The camera contrast used on this material.
  14492. */
  14493. cameraContrast: number;
  14494. /**
  14495. * Gets the Color Grading 2D Lookup Texture.
  14496. */
  14497. /**
  14498. * Sets the Color Grading 2D Lookup Texture.
  14499. */
  14500. cameraColorGradingTexture: Nullable<BaseTexture>;
  14501. /**
  14502. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14503. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14504. * 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;
  14505. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14506. */
  14507. /**
  14508. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14509. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14510. * 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;
  14511. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14512. */
  14513. cameraColorCurves: Nullable<ColorCurves>;
  14514. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14515. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14516. protected _worldViewProjectionMatrix: Matrix;
  14517. protected _globalAmbientColor: Color3;
  14518. protected _useLogarithmicDepth: boolean;
  14519. constructor(name: string, scene: Scene);
  14520. getClassName(): string;
  14521. useLogarithmicDepth: boolean;
  14522. needAlphaBlending(): boolean;
  14523. needAlphaTesting(): boolean;
  14524. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14525. getAlphaTestTexture(): Nullable<BaseTexture>;
  14526. /**
  14527. * Child classes can use it to update shaders
  14528. */
  14529. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14530. buildUniformLayout(): void;
  14531. unbind(): void;
  14532. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14533. getAnimatables(): IAnimatable[];
  14534. getActiveTextures(): BaseTexture[];
  14535. hasTexture(texture: BaseTexture): boolean;
  14536. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14537. clone(name: string): StandardMaterial;
  14538. serialize(): any;
  14539. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14540. static _DiffuseTextureEnabled: boolean;
  14541. static DiffuseTextureEnabled: boolean;
  14542. static _AmbientTextureEnabled: boolean;
  14543. static AmbientTextureEnabled: boolean;
  14544. static _OpacityTextureEnabled: boolean;
  14545. static OpacityTextureEnabled: boolean;
  14546. static _ReflectionTextureEnabled: boolean;
  14547. static ReflectionTextureEnabled: boolean;
  14548. static _EmissiveTextureEnabled: boolean;
  14549. static EmissiveTextureEnabled: boolean;
  14550. static _SpecularTextureEnabled: boolean;
  14551. static SpecularTextureEnabled: boolean;
  14552. static _BumpTextureEnabled: boolean;
  14553. static BumpTextureEnabled: boolean;
  14554. static _LightmapTextureEnabled: boolean;
  14555. static LightmapTextureEnabled: boolean;
  14556. static _RefractionTextureEnabled: boolean;
  14557. static RefractionTextureEnabled: boolean;
  14558. static _ColorGradingTextureEnabled: boolean;
  14559. static ColorGradingTextureEnabled: boolean;
  14560. static _FresnelEnabled: boolean;
  14561. static FresnelEnabled: boolean;
  14562. }
  14563. }
  14564. declare module BABYLON {
  14565. class UniformBuffer {
  14566. private _engine;
  14567. private _buffer;
  14568. private _data;
  14569. private _bufferData;
  14570. private _dynamic?;
  14571. private _uniformLocations;
  14572. private _uniformSizes;
  14573. private _uniformLocationPointer;
  14574. private _needSync;
  14575. private _noUBO;
  14576. private _currentEffect;
  14577. private static _MAX_UNIFORM_SIZE;
  14578. private static _tempBuffer;
  14579. /**
  14580. * Wrapper for updateUniform.
  14581. * @method updateMatrix3x3
  14582. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14583. * @param {Float32Array} matrix
  14584. */
  14585. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14586. /**
  14587. * Wrapper for updateUniform.
  14588. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14589. * @param {Float32Array} matrix
  14590. */
  14591. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14592. /**
  14593. * Wrapper for updateUniform.
  14594. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14595. * @param {number} x
  14596. */
  14597. updateFloat: (name: string, x: number) => void;
  14598. /**
  14599. * Wrapper for updateUniform.
  14600. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14601. * @param {number} x
  14602. * @param {number} y
  14603. * @param {string} [suffix] Suffix to add to the uniform name.
  14604. */
  14605. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14606. /**
  14607. * Wrapper for updateUniform.
  14608. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14609. * @param {number} x
  14610. * @param {number} y
  14611. * @param {number} z
  14612. * @param {string} [suffix] Suffix to add to the uniform name.
  14613. */
  14614. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14615. /**
  14616. * Wrapper for updateUniform.
  14617. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14618. * @param {number} x
  14619. * @param {number} y
  14620. * @param {number} z
  14621. * @param {number} w
  14622. * @param {string} [suffix] Suffix to add to the uniform name.
  14623. */
  14624. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14625. /**
  14626. * Wrapper for updateUniform.
  14627. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14628. * @param {Matrix} A 4x4 matrix.
  14629. */
  14630. updateMatrix: (name: string, mat: Matrix) => void;
  14631. /**
  14632. * Wrapper for updateUniform.
  14633. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14634. * @param {Vector3} vector
  14635. */
  14636. updateVector3: (name: string, vector: Vector3) => void;
  14637. /**
  14638. * Wrapper for updateUniform.
  14639. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14640. * @param {Vector4} vector
  14641. */
  14642. updateVector4: (name: string, vector: Vector4) => void;
  14643. /**
  14644. * Wrapper for updateUniform.
  14645. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14646. * @param {Color3} color
  14647. * @param {string} [suffix] Suffix to add to the uniform name.
  14648. */
  14649. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14650. /**
  14651. * Wrapper for updateUniform.
  14652. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14653. * @param {Color3} color
  14654. * @param {number} alpha
  14655. * @param {string} [suffix] Suffix to add to the uniform name.
  14656. */
  14657. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14658. /**
  14659. * Uniform buffer objects.
  14660. *
  14661. * Handles blocks of uniform on the GPU.
  14662. *
  14663. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14664. *
  14665. * For more information, please refer to :
  14666. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14667. */
  14668. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14669. /**
  14670. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14671. * or just falling back on setUniformXXX calls.
  14672. */
  14673. readonly useUbo: boolean;
  14674. /**
  14675. * Indicates if the WebGL underlying uniform buffer is in sync
  14676. * with the javascript cache data.
  14677. */
  14678. readonly isSync: boolean;
  14679. /**
  14680. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14681. * Also, a dynamic UniformBuffer will disable cache verification and always
  14682. * update the underlying WebGL uniform buffer to the GPU.
  14683. */
  14684. isDynamic(): boolean;
  14685. /**
  14686. * The data cache on JS side.
  14687. */
  14688. getData(): Float32Array;
  14689. /**
  14690. * The underlying WebGL Uniform buffer.
  14691. */
  14692. getBuffer(): Nullable<WebGLBuffer>;
  14693. /**
  14694. * std140 layout specifies how to align data within an UBO structure.
  14695. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14696. * for specs.
  14697. */
  14698. private _fillAlignment(size);
  14699. /**
  14700. * Adds an uniform in the buffer.
  14701. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  14702. * for the layout to be correct !
  14703. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14704. * @param {number|number[]} size Data size, or data directly.
  14705. */
  14706. addUniform(name: string, size: number | number[]): void;
  14707. /**
  14708. * Wrapper for addUniform.
  14709. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14710. * @param {Matrix} mat A 4x4 matrix.
  14711. */
  14712. addMatrix(name: string, mat: Matrix): void;
  14713. /**
  14714. * Wrapper for addUniform.
  14715. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14716. * @param {number} x
  14717. * @param {number} y
  14718. */
  14719. addFloat2(name: string, x: number, y: number): void;
  14720. /**
  14721. * Wrapper for addUniform.
  14722. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14723. * @param {number} x
  14724. * @param {number} y
  14725. * @param {number} z
  14726. */
  14727. addFloat3(name: string, x: number, y: number, z: number): void;
  14728. /**
  14729. * Wrapper for addUniform.
  14730. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14731. * @param {Color3} color
  14732. */
  14733. addColor3(name: string, color: Color3): void;
  14734. /**
  14735. * Wrapper for addUniform.
  14736. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14737. * @param {Color3} color
  14738. * @param {number} alpha
  14739. */
  14740. addColor4(name: string, color: Color3, alpha: number): void;
  14741. /**
  14742. * Wrapper for addUniform.
  14743. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14744. * @param {Vector3} vector
  14745. */
  14746. addVector3(name: string, vector: Vector3): void;
  14747. /**
  14748. * Wrapper for addUniform.
  14749. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14750. */
  14751. addMatrix3x3(name: string): void;
  14752. /**
  14753. * Wrapper for addUniform.
  14754. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14755. */
  14756. addMatrix2x2(name: string): void;
  14757. /**
  14758. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  14759. */
  14760. create(): void;
  14761. _rebuild(): void;
  14762. /**
  14763. * Updates the WebGL Uniform Buffer on the GPU.
  14764. * If the `dynamic` flag is set to true, no cache comparison is done.
  14765. * Otherwise, the buffer will be updated only if the cache differs.
  14766. */
  14767. update(): void;
  14768. /**
  14769. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  14770. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14771. * @param {number[]|Float32Array} data Flattened data
  14772. * @param {number} size Size of the data.
  14773. */
  14774. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  14775. private _updateMatrix3x3ForUniform(name, matrix);
  14776. private _updateMatrix3x3ForEffect(name, matrix);
  14777. private _updateMatrix2x2ForEffect(name, matrix);
  14778. private _updateMatrix2x2ForUniform(name, matrix);
  14779. private _updateFloatForEffect(name, x);
  14780. private _updateFloatForUniform(name, x);
  14781. private _updateFloat2ForEffect(name, x, y, suffix?);
  14782. private _updateFloat2ForUniform(name, x, y, suffix?);
  14783. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  14784. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  14785. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  14786. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  14787. private _updateMatrixForEffect(name, mat);
  14788. private _updateMatrixForUniform(name, mat);
  14789. private _updateVector3ForEffect(name, vector);
  14790. private _updateVector3ForUniform(name, vector);
  14791. private _updateVector4ForEffect(name, vector);
  14792. private _updateVector4ForUniform(name, vector);
  14793. private _updateColor3ForEffect(name, color, suffix?);
  14794. private _updateColor3ForUniform(name, color, suffix?);
  14795. private _updateColor4ForEffect(name, color, alpha, suffix?);
  14796. private _updateColor4ForUniform(name, color, alpha, suffix?);
  14797. /**
  14798. * Sets a sampler uniform on the effect.
  14799. * @param {string} name Name of the sampler.
  14800. * @param {Texture} texture
  14801. */
  14802. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  14803. /**
  14804. * Directly updates the value of the uniform in the cache AND on the GPU.
  14805. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14806. * @param {number[]|Float32Array} data Flattened data
  14807. */
  14808. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  14809. /**
  14810. * Binds this uniform buffer to an effect.
  14811. * @param {Effect} effect
  14812. * @param {string} name Name of the uniform block in the shader.
  14813. */
  14814. bindToEffect(effect: Effect, name: string): void;
  14815. /**
  14816. * Disposes the uniform buffer.
  14817. */
  14818. dispose(): void;
  14819. }
  14820. }
  14821. declare module BABYLON {
  14822. class Scalar {
  14823. /**
  14824. * Two pi constants convenient for computation.
  14825. */
  14826. static TwoPi: number;
  14827. /**
  14828. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14829. */
  14830. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14831. /**
  14832. * Returns a string : the upper case translation of the number i to hexadecimal.
  14833. */
  14834. static ToHex(i: number): string;
  14835. /**
  14836. * Returns -1 if value is negative and +1 is value is positive.
  14837. * Returns the value itself if it's equal to zero.
  14838. */
  14839. static Sign(value: number): number;
  14840. /**
  14841. * Returns the value itself if it's between min and max.
  14842. * Returns min if the value is lower than min.
  14843. * Returns max if the value is greater than max.
  14844. */
  14845. static Clamp(value: number, min?: number, max?: number): number;
  14846. /**
  14847. * Returns the log2 of value.
  14848. */
  14849. static Log2(value: number): number;
  14850. /**
  14851. * Loops the value, so that it is never larger than length and never smaller than 0.
  14852. *
  14853. * This is similar to the modulo operator but it works with floating point numbers.
  14854. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14855. * With t = 5 and length = 2.5, the result would be 0.0.
  14856. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14857. */
  14858. static Repeat(value: number, length: number): number;
  14859. /**
  14860. * Normalize the value between 0.0 and 1.0 using min and max values
  14861. */
  14862. static Normalize(value: number, min: number, max: number): number;
  14863. /**
  14864. * Denormalize the value from 0.0 and 1.0 using min and max values
  14865. */
  14866. static Denormalize(normalized: number, min: number, max: number): number;
  14867. /**
  14868. * Calculates the shortest difference between two given angles given in degrees.
  14869. */
  14870. static DeltaAngle(current: number, target: number): number;
  14871. /**
  14872. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14873. *
  14874. * The returned value will move back and forth between 0 and length
  14875. */
  14876. static PingPong(tx: number, length: number): number;
  14877. /**
  14878. * Interpolates between min and max with smoothing at the limits.
  14879. *
  14880. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14881. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14882. */
  14883. static SmoothStep(from: number, to: number, tx: number): number;
  14884. /**
  14885. * Moves a value current towards target.
  14886. *
  14887. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14888. * Negative values of maxDelta pushes the value away from target.
  14889. */
  14890. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14891. /**
  14892. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14893. *
  14894. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14895. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14896. */
  14897. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14898. /**
  14899. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14900. */
  14901. static Lerp(start: number, end: number, amount: number): number;
  14902. /**
  14903. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14904. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14905. */
  14906. static LerpAngle(start: number, end: number, amount: number): number;
  14907. /**
  14908. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14909. */
  14910. static InverseLerp(a: number, b: number, value: number): number;
  14911. /**
  14912. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14913. */
  14914. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14915. /**
  14916. * Returns a random float number between and min and max values
  14917. */
  14918. static RandomRange(min: number, max: number): number;
  14919. /**
  14920. * This function returns percentage of a number in a given range.
  14921. *
  14922. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14923. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14924. */
  14925. static RangeToPercent(number: number, min: number, max: number): number;
  14926. /**
  14927. * This function returns number that corresponds to the percentage in a given range.
  14928. *
  14929. * PercentToRange(0.34,0,100) will return 34.
  14930. */
  14931. static PercentToRange(percent: number, min: number, max: number): number;
  14932. /**
  14933. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14934. * @param angle The angle to normalize in radian.
  14935. * @return The converted angle.
  14936. */
  14937. static NormalizeRadians(angle: number): number;
  14938. }
  14939. }
  14940. declare module BABYLON {
  14941. const ToGammaSpace: number;
  14942. const ToLinearSpace = 2.2;
  14943. const Epsilon = 0.001;
  14944. /**
  14945. * Class used to hold a RBG color
  14946. */
  14947. class Color3 {
  14948. /**
  14949. * Defines the red component (between 0 and 1, default is 0)
  14950. */
  14951. r: number;
  14952. /**
  14953. * Defines the green component (between 0 and 1, default is 0)
  14954. */
  14955. g: number;
  14956. /**
  14957. * Defines the blue component (between 0 and 1, default is 0)
  14958. */
  14959. b: number;
  14960. /**
  14961. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14962. * @param r defines the red component (between 0 and 1, default is 0)
  14963. * @param g defines the green component (between 0 and 1, default is 0)
  14964. * @param b defines the blue component (between 0 and 1, default is 0)
  14965. */
  14966. constructor(
  14967. /**
  14968. * Defines the red component (between 0 and 1, default is 0)
  14969. */
  14970. r?: number,
  14971. /**
  14972. * Defines the green component (between 0 and 1, default is 0)
  14973. */
  14974. g?: number,
  14975. /**
  14976. * Defines the blue component (between 0 and 1, default is 0)
  14977. */
  14978. b?: number);
  14979. /**
  14980. * Creates a string with the Color3 current values
  14981. * @returns the string representation of the Color3 object
  14982. */
  14983. toString(): string;
  14984. /**
  14985. * Returns the string "Color3"
  14986. * @returns "Color3"
  14987. */
  14988. getClassName(): string;
  14989. /**
  14990. * Compute the Color3 hash code
  14991. * @returns an unique number that can be used to hash Color3 objects
  14992. */
  14993. getHashCode(): number;
  14994. /**
  14995. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  14996. * @param array defines the array where to store the r,g,b components
  14997. * @param index defines an optional index in the target array to define where to start storing values
  14998. * @returns the current Color3 object
  14999. */
  15000. toArray(array: FloatArray, index?: number): Color3;
  15001. /**
  15002. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15003. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15004. * @returns a new {BABYLON.Color4} object
  15005. */
  15006. toColor4(alpha?: number): Color4;
  15007. /**
  15008. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15009. * @returns the new array
  15010. */
  15011. asArray(): number[];
  15012. /**
  15013. * Returns the luminance value
  15014. * @returns a float value
  15015. */
  15016. toLuminance(): number;
  15017. /**
  15018. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15019. * @param otherColor defines the second operand
  15020. * @returns the new Color3 object
  15021. */
  15022. multiply(otherColor: Color3): Color3;
  15023. /**
  15024. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15025. * @param otherColor defines the second operand
  15026. * @param result defines the Color3 object where to store the result
  15027. * @returns the current Color3
  15028. */
  15029. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15030. /**
  15031. * Determines equality between Color3 objects
  15032. * @param otherColor defines the second operand
  15033. * @returns true if the rgb values are equal to the given ones
  15034. */
  15035. equals(otherColor: Color3): boolean;
  15036. /**
  15037. * Determines equality between the current Color3 object and a set of r,b,g values
  15038. * @param r defines the red component to check
  15039. * @param g defines the green component to check
  15040. * @param b defines the blue component to check
  15041. * @returns true if the rgb values are equal to the given ones
  15042. */
  15043. equalsFloats(r: number, g: number, b: number): boolean;
  15044. /**
  15045. * Multiplies in place each rgb value by scale
  15046. * @param scale defines the scaling factor
  15047. * @returns the updated Color3
  15048. */
  15049. scale(scale: number): Color3;
  15050. /**
  15051. * Multiplies the rgb values by scale and stores the result into "result"
  15052. * @param scale defines the scaling factor
  15053. * @param result defines the Color3 object where to store the result
  15054. * @returns the unmodified current Color3
  15055. */
  15056. scaleToRef(scale: number, result: Color3): Color3;
  15057. /**
  15058. * Scale the current Color3 values by a factor and add the result to a given Color3
  15059. * @param scale defines the scale factor
  15060. * @param result defines color to store the result into
  15061. * @returns the unmodified current Color3
  15062. */
  15063. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15064. /**
  15065. * Clamps the rgb values by the min and max values and stores the result into "result"
  15066. * @param min defines minimum clamping value (default is 0)
  15067. * @param max defines maximum clamping value (default is 1)
  15068. * @param result defines color to store the result into
  15069. * @returns the original Color3
  15070. */
  15071. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15072. /**
  15073. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15074. * @param otherColor defines the second operand
  15075. * @returns the new Color3
  15076. */
  15077. add(otherColor: Color3): Color3;
  15078. /**
  15079. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15080. * @param otherColor defines the second operand
  15081. * @param result defines Color3 object to store the result into
  15082. * @returns the unmodified current Color3
  15083. */
  15084. addToRef(otherColor: Color3, result: Color3): Color3;
  15085. /**
  15086. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15087. * @param otherColor defines the second operand
  15088. * @returns the new Color3
  15089. */
  15090. subtract(otherColor: Color3): Color3;
  15091. /**
  15092. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15093. * @param otherColor defines the second operand
  15094. * @param result defines Color3 object to store the result into
  15095. * @returns the unmodified current Color3
  15096. */
  15097. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15098. /**
  15099. * Copy the current object
  15100. * @returns a new Color3 copied the current one
  15101. */
  15102. clone(): Color3;
  15103. /**
  15104. * Copies the rgb values from the source in the current Color3
  15105. * @param source defines the source Color3 object
  15106. * @returns the updated Color3 object
  15107. */
  15108. copyFrom(source: Color3): Color3;
  15109. /**
  15110. * Updates the Color3 rgb values from the given floats
  15111. * @param r defines the red component to read from
  15112. * @param g defines the green component to read from
  15113. * @param b defines the blue component to read from
  15114. * @returns the current Color3 object
  15115. */
  15116. copyFromFloats(r: number, g: number, b: number): Color3;
  15117. /**
  15118. * Updates the Color3 rgb values from the given floats
  15119. * @param r defines the red component to read from
  15120. * @param g defines the green component to read from
  15121. * @param b defines the blue component to read from
  15122. * @returns the current Color3 object
  15123. */
  15124. set(r: number, g: number, b: number): Color3;
  15125. /**
  15126. * Compute the Color3 hexadecimal code as a string
  15127. * @returns a string containing the hexadecimal representation of the Color3 object
  15128. */
  15129. toHexString(): string;
  15130. /**
  15131. * Computes a new Color3 converted from the current one to linear space
  15132. * @returns a new Color3 object
  15133. */
  15134. toLinearSpace(): Color3;
  15135. /**
  15136. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15137. * @param convertedColor defines the Color3 object where to store the linear space version
  15138. * @returns the unmodified Color3
  15139. */
  15140. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15141. /**
  15142. * Computes a new Color3 converted from the current one to gamma space
  15143. * @returns a new Color3 object
  15144. */
  15145. toGammaSpace(): Color3;
  15146. /**
  15147. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15148. * @param convertedColor defines the Color3 object where to store the gamma space version
  15149. * @returns the unmodified Color3
  15150. */
  15151. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15152. /**
  15153. * Creates a new Color3 from the string containing valid hexadecimal values
  15154. * @param hex defines a string containing valid hexadecimal values
  15155. * @returns a new Color3 object
  15156. */
  15157. static FromHexString(hex: string): Color3;
  15158. /**
  15159. * Creates a new Vector3 from the starting index of the given array
  15160. * @param array defines the source array
  15161. * @param offset defines an offset in the source array
  15162. * @returns a new Color3 object
  15163. */
  15164. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15165. /**
  15166. * Creates a new Color3 from integer values (< 256)
  15167. * @param r defines the red component to read from (value between 0 and 255)
  15168. * @param g defines the green component to read from (value between 0 and 255)
  15169. * @param b defines the blue component to read from (value between 0 and 255)
  15170. * @returns a new Color3 object
  15171. */
  15172. static FromInts(r: number, g: number, b: number): Color3;
  15173. /**
  15174. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15175. * @param start defines the start Color3 value
  15176. * @param end defines the end Color3 value
  15177. * @param amount defines the gradient value between start and end
  15178. * @returns a new Color3 object
  15179. */
  15180. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15181. /**
  15182. * Returns a Color3 value containing a red color
  15183. * @returns a new Color3 object
  15184. */
  15185. static Red(): Color3;
  15186. /**
  15187. * Returns a Color3 value containing a green color
  15188. * @returns a new Color3 object
  15189. */
  15190. static Green(): Color3;
  15191. /**
  15192. * Returns a Color3 value containing a blue color
  15193. * @returns a new Color3 object
  15194. */
  15195. static Blue(): Color3;
  15196. /**
  15197. * Returns a Color3 value containing a black color
  15198. * @returns a new Color3 object
  15199. */
  15200. static Black(): Color3;
  15201. /**
  15202. * Returns a Color3 value containing a white color
  15203. * @returns a new Color3 object
  15204. */
  15205. static White(): Color3;
  15206. /**
  15207. * Returns a Color3 value containing a purple color
  15208. * @returns a new Color3 object
  15209. */
  15210. static Purple(): Color3;
  15211. /**
  15212. * Returns a Color3 value containing a magenta color
  15213. * @returns a new Color3 object
  15214. */
  15215. static Magenta(): Color3;
  15216. /**
  15217. * Returns a Color3 value containing a yellow color
  15218. * @returns a new Color3 object
  15219. */
  15220. static Yellow(): Color3;
  15221. /**
  15222. * Returns a Color3 value containing a gray color
  15223. * @returns a new Color3 object
  15224. */
  15225. static Gray(): Color3;
  15226. /**
  15227. * Returns a Color3 value containing a teal color
  15228. * @returns a new Color3 object
  15229. */
  15230. static Teal(): Color3;
  15231. /**
  15232. * Returns a Color3 value containing a random color
  15233. * @returns a new Color3 object
  15234. */
  15235. static Random(): Color3;
  15236. }
  15237. /**
  15238. * Class used to hold a RBGA color
  15239. */
  15240. class Color4 {
  15241. /**
  15242. * Defines the red component (between 0 and 1, default is 0)
  15243. */
  15244. r: number;
  15245. /**
  15246. * Defines the green component (between 0 and 1, default is 0)
  15247. */
  15248. g: number;
  15249. /**
  15250. * Defines the blue component (between 0 and 1, default is 0)
  15251. */
  15252. b: number;
  15253. /**
  15254. * Defines the alpha component (between 0 and 1, default is 1)
  15255. */
  15256. a: number;
  15257. /**
  15258. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15259. * @param r defines the red component (between 0 and 1, default is 0)
  15260. * @param g defines the green component (between 0 and 1, default is 0)
  15261. * @param b defines the blue component (between 0 and 1, default is 0)
  15262. * @param a defines the alpha component (between 0 and 1, default is 1)
  15263. */
  15264. constructor(
  15265. /**
  15266. * Defines the red component (between 0 and 1, default is 0)
  15267. */
  15268. r?: number,
  15269. /**
  15270. * Defines the green component (between 0 and 1, default is 0)
  15271. */
  15272. g?: number,
  15273. /**
  15274. * Defines the blue component (between 0 and 1, default is 0)
  15275. */
  15276. b?: number,
  15277. /**
  15278. * Defines the alpha component (between 0 and 1, default is 1)
  15279. */
  15280. a?: number);
  15281. /**
  15282. * Adds in place the given Color4 values to the current Color4 object
  15283. * @param right defines the second operand
  15284. * @returns the current updated Color4 object
  15285. */
  15286. addInPlace(right: Color4): Color4;
  15287. /**
  15288. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15289. * @returns the new array
  15290. */
  15291. asArray(): number[];
  15292. /**
  15293. * Stores from the starting index in the given array the Color4 successive values
  15294. * @param array defines the array where to store the r,g,b components
  15295. * @param index defines an optional index in the target array to define where to start storing values
  15296. * @returns the current Color4 object
  15297. */
  15298. toArray(array: number[], index?: number): Color4;
  15299. /**
  15300. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15301. * @param right defines the second operand
  15302. * @returns a new Color4 object
  15303. */
  15304. add(right: Color4): Color4;
  15305. /**
  15306. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15307. * @param right defines the second operand
  15308. * @returns a new Color4 object
  15309. */
  15310. subtract(right: Color4): Color4;
  15311. /**
  15312. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15313. * @param right defines the second operand
  15314. * @param result defines the Color4 object where to store the result
  15315. * @returns the current Color4 object
  15316. */
  15317. subtractToRef(right: Color4, result: Color4): Color4;
  15318. /**
  15319. * Creates a new Color4 with the current Color4 values multiplied by scale
  15320. * @param scale defines the scaling factor to apply
  15321. * @returns a new Color4 object
  15322. */
  15323. scale(scale: number): Color4;
  15324. /**
  15325. * Multiplies the current Color4 values by scale and stores the result in "result"
  15326. * @param scale defines the scaling factor to apply
  15327. * @param result defines the Color4 object where to store the result
  15328. * @returns the current unmodified Color4
  15329. */
  15330. scaleToRef(scale: number, result: Color4): Color4;
  15331. /**
  15332. * Scale the current Color4 values by a factor and add the result to a given Color4
  15333. * @param scale defines the scale factor
  15334. * @param result defines the Color4 object where to store the result
  15335. * @returns the unmodified current Color4
  15336. */
  15337. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15338. /**
  15339. * Clamps the rgb values by the min and max values and stores the result into "result"
  15340. * @param min defines minimum clamping value (default is 0)
  15341. * @param max defines maximum clamping value (default is 1)
  15342. * @param result defines color to store the result into.
  15343. * @returns the cuurent Color4
  15344. */
  15345. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15346. /**
  15347. * Multipy an Color4 value by another and return a new Color4 object
  15348. * @param color defines the Color4 value to multiply by
  15349. * @returns a new Color4 object
  15350. */
  15351. multiply(color: Color4): Color4;
  15352. /**
  15353. * Multipy a Color4 value by another and push the result in a reference value
  15354. * @param color defines the Color4 value to multiply by
  15355. * @param result defines the Color4 to fill the result in
  15356. * @returns the result Color4
  15357. */
  15358. multiplyToRef(color: Color4, result: Color4): Color4;
  15359. /**
  15360. * Creates a string with the Color4 current values
  15361. * @returns the string representation of the Color4 object
  15362. */
  15363. toString(): string;
  15364. /**
  15365. * Returns the string "Color4"
  15366. * @returns "Color4"
  15367. */
  15368. getClassName(): string;
  15369. /**
  15370. * Compute the Color4 hash code
  15371. * @returns an unique number that can be used to hash Color4 objects
  15372. */
  15373. getHashCode(): number;
  15374. /**
  15375. * Creates a new Color4 copied from the current one
  15376. * @returns a new Color4 object
  15377. */
  15378. clone(): Color4;
  15379. /**
  15380. * Copies the given Color4 values into the current one
  15381. * @param source defines the source Color4 object
  15382. * @returns the current updated Color4 object
  15383. */
  15384. copyFrom(source: Color4): Color4;
  15385. /**
  15386. * Copies the given float values into the current one
  15387. * @param r defines the red component to read from
  15388. * @param g defines the green component to read from
  15389. * @param b defines the blue component to read from
  15390. * @param a defines the alpha component to read from
  15391. * @returns the current updated Color4 object
  15392. */
  15393. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15394. /**
  15395. * Copies the given float values into the current one
  15396. * @param r defines the red component to read from
  15397. * @param g defines the green component to read from
  15398. * @param b defines the blue component to read from
  15399. * @param a defines the alpha component to read from
  15400. * @returns the current updated Color4 object
  15401. */
  15402. set(r: number, g: number, b: number, a: number): Color4;
  15403. /**
  15404. * Compute the Color4 hexadecimal code as a string
  15405. * @returns a string containing the hexadecimal representation of the Color4 object
  15406. */
  15407. toHexString(): string;
  15408. /**
  15409. * Computes a new Color4 converted from the current one to linear space
  15410. * @returns a new Color4 object
  15411. */
  15412. toLinearSpace(): Color4;
  15413. /**
  15414. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15415. * @param convertedColor defines the Color4 object where to store the linear space version
  15416. * @returns the unmodified Color4
  15417. */
  15418. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15419. /**
  15420. * Computes a new Color4 converted from the current one to gamma space
  15421. * @returns a new Color4 object
  15422. */
  15423. toGammaSpace(): Color4;
  15424. /**
  15425. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15426. * @param convertedColor defines the Color4 object where to store the gamma space version
  15427. * @returns the unmodified Color4
  15428. */
  15429. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15430. /**
  15431. * Creates a new Color4 from the string containing valid hexadecimal values
  15432. * @param hex defines a string containing valid hexadecimal values
  15433. * @returns a new Color4 object
  15434. */
  15435. static FromHexString(hex: string): Color4;
  15436. /**
  15437. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15438. * @param left defines the start value
  15439. * @param right defines the end value
  15440. * @param amount defines the gradient factor
  15441. * @returns a new Color4 object
  15442. */
  15443. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15444. /**
  15445. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15446. * @param left defines the start value
  15447. * @param right defines the end value
  15448. * @param amount defines the gradient factor
  15449. * @param result defines the Color4 object where to store data
  15450. */
  15451. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15452. /**
  15453. * Creates a new Color4 from the starting index element of the given array
  15454. * @param array defines the source array to read from
  15455. * @param offset defines the offset in the source array
  15456. * @returns a new Color4 object
  15457. */
  15458. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15459. /**
  15460. * Creates a new Color3 from integer values (< 256)
  15461. * @param r defines the red component to read from (value between 0 and 255)
  15462. * @param g defines the green component to read from (value between 0 and 255)
  15463. * @param b defines the blue component to read from (value between 0 and 255)
  15464. * @param a defines the alpha component to read from (value between 0 and 255)
  15465. * @returns a new Color3 object
  15466. */
  15467. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15468. /**
  15469. * Check the content of a given array and convert it to an array containing RGBA data
  15470. * If the original array was already containing count * 4 values then it is returned directly
  15471. * @param colors defines the array to check
  15472. * @param count defines the number of RGBA data to expect
  15473. * @returns an array containing count * 4 values (RGBA)
  15474. */
  15475. static CheckColors4(colors: number[], count: number): number[];
  15476. }
  15477. /**
  15478. * Class representing a vector containing 2 coordinates
  15479. */
  15480. class Vector2 {
  15481. /** defines the first coordinate */
  15482. x: number;
  15483. /** defines the second coordinate */
  15484. y: number;
  15485. /**
  15486. * Creates a new Vector2 from the given x and y coordinates
  15487. * @param x defines the first coordinate
  15488. * @param y defines the second coordinate
  15489. */
  15490. constructor(
  15491. /** defines the first coordinate */
  15492. x: number,
  15493. /** defines the second coordinate */
  15494. y: number);
  15495. /**
  15496. * Gets a string with the Vector2 coordinates
  15497. * @returns a string with the Vector2 coordinates
  15498. */
  15499. toString(): string;
  15500. /**
  15501. * Gets class name
  15502. * @returns the string "Vector2"
  15503. */
  15504. getClassName(): string;
  15505. /**
  15506. * Gets current vector hash code
  15507. * @returns the Vector2 hash code as a number
  15508. */
  15509. getHashCode(): number;
  15510. /**
  15511. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15512. * @param array defines the source array
  15513. * @param index defines the offset in source array
  15514. * @returns the current Vector2
  15515. */
  15516. toArray(array: FloatArray, index?: number): Vector2;
  15517. /**
  15518. * Copy the current vector to an array
  15519. * @returns a new array with 2 elements: the Vector2 coordinates.
  15520. */
  15521. asArray(): number[];
  15522. /**
  15523. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15524. * @param source defines the source Vector2
  15525. * @returns the current updated Vector2
  15526. */
  15527. copyFrom(source: Vector2): Vector2;
  15528. /**
  15529. * Sets the Vector2 coordinates with the given floats
  15530. * @param x defines the first coordinate
  15531. * @param y defines the second coordinate
  15532. * @returns the current updated Vector2
  15533. */
  15534. copyFromFloats(x: number, y: number): Vector2;
  15535. /**
  15536. * Sets the Vector2 coordinates with the given floats
  15537. * @param x defines the first coordinate
  15538. * @param y defines the second coordinate
  15539. * @returns the current updated Vector2
  15540. */
  15541. set(x: number, y: number): Vector2;
  15542. /**
  15543. * Add another vector with the current one
  15544. * @param otherVector defines the other vector
  15545. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15546. */
  15547. add(otherVector: Vector2): Vector2;
  15548. /**
  15549. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15550. * @param otherVector defines the other vector
  15551. * @param result defines the target vector
  15552. * @returns the unmodified current Vector2
  15553. */
  15554. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15555. /**
  15556. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15557. * @param otherVector defines the other vector
  15558. * @returns the current updated Vector2
  15559. */
  15560. addInPlace(otherVector: Vector2): Vector2;
  15561. /**
  15562. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15563. * @param otherVector defines the other vector
  15564. * @returns a new Vector2
  15565. */
  15566. addVector3(otherVector: Vector3): Vector2;
  15567. /**
  15568. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15569. * @param otherVector defines the other vector
  15570. * @returns a new Vector2
  15571. */
  15572. subtract(otherVector: Vector2): Vector2;
  15573. /**
  15574. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15575. * @param otherVector defines the other vector
  15576. * @param result defines the target vector
  15577. * @returns the unmodified current Vector2
  15578. */
  15579. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15580. /**
  15581. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15582. * @param otherVector defines the other vector
  15583. * @returns the current updated Vector2
  15584. */
  15585. subtractInPlace(otherVector: Vector2): Vector2;
  15586. /**
  15587. * Multiplies in place the current Vector2 coordinates by the given ones
  15588. * @param otherVector defines the other vector
  15589. * @returns the current updated Vector2
  15590. */
  15591. multiplyInPlace(otherVector: Vector2): Vector2;
  15592. /**
  15593. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15594. * @param otherVector defines the other vector
  15595. * @returns a new Vector2
  15596. */
  15597. multiply(otherVector: Vector2): Vector2;
  15598. /**
  15599. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15600. * @param otherVector defines the other vector
  15601. * @param result defines the target vector
  15602. * @returns the unmodified current Vector2
  15603. */
  15604. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15605. /**
  15606. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15607. * @param x defines the first coordinate
  15608. * @param y defines the second coordinate
  15609. * @returns a new Vector2
  15610. */
  15611. multiplyByFloats(x: number, y: number): Vector2;
  15612. /**
  15613. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15614. * @param otherVector defines the other vector
  15615. * @returns a new Vector2
  15616. */
  15617. divide(otherVector: Vector2): Vector2;
  15618. /**
  15619. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15620. * @param otherVector defines the other vector
  15621. * @param result defines the target vector
  15622. * @returns the unmodified current Vector2
  15623. */
  15624. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15625. /**
  15626. * Divides the current Vector3 coordinates by the given ones
  15627. * @param otherVector defines the other vector
  15628. * @returns the current updated Vector2
  15629. */
  15630. divideInPlace(otherVector: Vector2): Vector2;
  15631. /**
  15632. * Gets a new Vector2 with current Vector2 negated coordinates
  15633. * @returns a new Vector2
  15634. */
  15635. negate(): Vector2;
  15636. /**
  15637. * Multiply the Vector2 coordinates by scale
  15638. * @param scale defines the scaling factor
  15639. * @returns the current updated Vector2
  15640. */
  15641. scaleInPlace(scale: number): Vector2;
  15642. /**
  15643. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15644. * @param scale defines the scaling factor
  15645. * @returns a new Vector2
  15646. */
  15647. scale(scale: number): Vector2;
  15648. /**
  15649. * Scale the current Vector2 values by a factor to a given Vector2
  15650. * @param scale defines the scale factor
  15651. * @param result defines the Vector2 object where to store the result
  15652. * @returns the unmodified current Vector2
  15653. */
  15654. scaleToRef(scale: number, result: Vector2): Vector2;
  15655. /**
  15656. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15657. * @param scale defines the scale factor
  15658. * @param result defines the Vector2 object where to store the result
  15659. * @returns the unmodified current Vector2
  15660. */
  15661. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15662. /**
  15663. * Gets a boolean if two vectors are equals
  15664. * @param otherVector defines the other vector
  15665. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15666. */
  15667. equals(otherVector: Vector2): boolean;
  15668. /**
  15669. * Gets a boolean if two vectors are equals (using an epsilon value)
  15670. * @param otherVector defines the other vector
  15671. * @param epsilon defines the minimal distance to consider equality
  15672. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15673. */
  15674. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15675. /**
  15676. * Gets the length of the vector
  15677. * @returns the vector length (float)
  15678. */
  15679. length(): number;
  15680. /**
  15681. * Gets the vector squared length
  15682. * @returns the vector squared length (float)
  15683. */
  15684. lengthSquared(): number;
  15685. /**
  15686. * Normalize the vector
  15687. * @returns the current updated Vector2
  15688. */
  15689. normalize(): Vector2;
  15690. /**
  15691. * Gets a new Vector2 copied from the Vector2
  15692. * @returns a new Vector2
  15693. */
  15694. clone(): Vector2;
  15695. /**
  15696. * Gets a new Vector2(0, 0)
  15697. * @returns a new Vector2
  15698. */
  15699. static Zero(): Vector2;
  15700. /**
  15701. * Gets a new Vector2(1, 1)
  15702. * @returns a new Vector2
  15703. */
  15704. static One(): Vector2;
  15705. /**
  15706. * Gets a new Vector2 set from the given index element of the given array
  15707. * @param array defines the data source
  15708. * @param offset defines the offset in the data source
  15709. * @returns a new Vector2
  15710. */
  15711. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15712. /**
  15713. * Sets "result" from the given index element of the given array
  15714. * @param array defines the data source
  15715. * @param offset defines the offset in the data source
  15716. * @param result defines the target vector
  15717. */
  15718. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15719. /**
  15720. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15721. * @param value1 defines 1st point of control
  15722. * @param value2 defines 2nd point of control
  15723. * @param value3 defines 3rd point of control
  15724. * @param value4 defines 4th point of control
  15725. * @param amount defines the interpolation factor
  15726. * @returns a new Vector2
  15727. */
  15728. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15729. /**
  15730. * 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".
  15731. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15732. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15733. * @param value defines the value to clamp
  15734. * @param min defines the lower limit
  15735. * @param max defines the upper limit
  15736. * @returns a new Vector2
  15737. */
  15738. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15739. /**
  15740. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15741. * @param value1 defines the 1st control point
  15742. * @param tangent1 defines the outgoing tangent
  15743. * @param value2 defines the 2nd control point
  15744. * @param tangent2 defines the incoming tangent
  15745. * @param amount defines the interpolation factor
  15746. * @returns a new Vector2
  15747. */
  15748. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15749. /**
  15750. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15751. * @param start defines the start vector
  15752. * @param end defines the end vector
  15753. * @param amount defines the interpolation factor
  15754. * @returns a new Vector2
  15755. */
  15756. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15757. /**
  15758. * Gets the dot product of the vector "left" and the vector "right"
  15759. * @param left defines first vector
  15760. * @param right defines second vector
  15761. * @returns the dot product (float)
  15762. */
  15763. static Dot(left: Vector2, right: Vector2): number;
  15764. /**
  15765. * Returns a new Vector2 equal to the normalized given vector
  15766. * @param vector defines the vector to normalize
  15767. * @returns a new Vector2
  15768. */
  15769. static Normalize(vector: Vector2): Vector2;
  15770. /**
  15771. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15772. * @param left defines 1st vector
  15773. * @param right defines 2nd vector
  15774. * @returns a new Vector2
  15775. */
  15776. static Minimize(left: Vector2, right: Vector2): Vector2;
  15777. /**
  15778. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15779. * @param left defines 1st vector
  15780. * @param right defines 2nd vector
  15781. * @returns a new Vector2
  15782. */
  15783. static Maximize(left: Vector2, right: Vector2): Vector2;
  15784. /**
  15785. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  15786. * @param vector defines the vector to transform
  15787. * @param transformation defines the matrix to apply
  15788. * @returns a new Vector2
  15789. */
  15790. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15791. /**
  15792. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  15793. * @param vector defines the vector to transform
  15794. * @param transformation defines the matrix to apply
  15795. * @param result defines the target vector
  15796. */
  15797. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15798. /**
  15799. * Determines if a given vector is included in a triangle
  15800. * @param p defines the vector to test
  15801. * @param p0 defines 1st triangle point
  15802. * @param p1 defines 2nd triangle point
  15803. * @param p2 defines 3rd triangle point
  15804. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15805. */
  15806. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15807. /**
  15808. * Gets the distance between the vectors "value1" and "value2"
  15809. * @param value1 defines first vector
  15810. * @param value2 defines second vector
  15811. * @returns the distance between vectors
  15812. */
  15813. static Distance(value1: Vector2, value2: Vector2): number;
  15814. /**
  15815. * Returns the squared distance between the vectors "value1" and "value2"
  15816. * @param value1 defines first vector
  15817. * @param value2 defines second vector
  15818. * @returns the squared distance between vectors
  15819. */
  15820. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15821. /**
  15822. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  15823. * @param value1 defines first vector
  15824. * @param value2 defines second vector
  15825. * @returns a new Vector2
  15826. */
  15827. static Center(value1: Vector2, value2: Vector2): Vector2;
  15828. /**
  15829. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15830. * @param p defines the middle point
  15831. * @param segA defines one point of the segment
  15832. * @param segB defines the other point of the segment
  15833. * @returns the shortest distance
  15834. */
  15835. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15836. }
  15837. /**
  15838. * Classed used to store (x,y,z) vector representation
  15839. * A Vector3 is the main object used in 3D geometry
  15840. * It can represent etiher the coordinates of a point the space, either a direction
  15841. * Reminder: Babylon.js uses a left handed forward facing system
  15842. */
  15843. class Vector3 {
  15844. /**
  15845. * Defines the first coordinates (on X axis)
  15846. */
  15847. x: number;
  15848. /**
  15849. * Defines the second coordinates (on Y axis)
  15850. */
  15851. y: number;
  15852. /**
  15853. * Defines the third coordinates (on Z axis)
  15854. */
  15855. z: number;
  15856. /**
  15857. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  15858. * @param x defines the first coordinates (on X axis)
  15859. * @param y defines the second coordinates (on Y axis)
  15860. * @param z defines the third coordinates (on Z axis)
  15861. */
  15862. constructor(
  15863. /**
  15864. * Defines the first coordinates (on X axis)
  15865. */
  15866. x: number,
  15867. /**
  15868. * Defines the second coordinates (on Y axis)
  15869. */
  15870. y: number,
  15871. /**
  15872. * Defines the third coordinates (on Z axis)
  15873. */
  15874. z: number);
  15875. /**
  15876. * Creates a string representation of the Vector3
  15877. * @returns a string with the Vector3 coordinates.
  15878. */
  15879. toString(): string;
  15880. /**
  15881. * Gets the class name
  15882. * @returns the string "Vector3"
  15883. */
  15884. getClassName(): string;
  15885. /**
  15886. * Creates the Vector3 hash code
  15887. * @returns a number which tends to be unique between Vector3 instances
  15888. */
  15889. getHashCode(): number;
  15890. /**
  15891. * Creates an array containing three elements : the coordinates of the Vector3
  15892. * @returns a new array of numbers
  15893. */
  15894. asArray(): number[];
  15895. /**
  15896. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  15897. * @param array defines the destination array
  15898. * @param index defines the offset in the destination array
  15899. * @returns the current Vector3
  15900. */
  15901. toArray(array: FloatArray, index?: number): Vector3;
  15902. /**
  15903. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15904. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15905. */
  15906. toQuaternion(): Quaternion;
  15907. /**
  15908. * Adds the given vector to the current Vector3
  15909. * @param otherVector defines the second operand
  15910. * @returns the current updated Vector3
  15911. */
  15912. addInPlace(otherVector: Vector3): Vector3;
  15913. /**
  15914. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  15915. * @param otherVector defines the second operand
  15916. * @returns the resulting Vector3
  15917. */
  15918. add(otherVector: Vector3): Vector3;
  15919. /**
  15920. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  15921. * @param otherVector defines the second operand
  15922. * @param result defines the Vector3 object where to store the result
  15923. * @returns the current Vector3
  15924. */
  15925. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15926. /**
  15927. * Subtract the given vector from the current Vector3
  15928. * @param otherVector defines the second operand
  15929. * @returns the current updated Vector3
  15930. */
  15931. subtractInPlace(otherVector: Vector3): Vector3;
  15932. /**
  15933. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  15934. * @param otherVector defines the second operand
  15935. * @returns the resulting Vector3
  15936. */
  15937. subtract(otherVector: Vector3): Vector3;
  15938. /**
  15939. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  15940. * @param otherVector defines the second operand
  15941. * @param result defines the Vector3 object where to store the result
  15942. * @returns the current Vector3
  15943. */
  15944. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15945. /**
  15946. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  15947. * @param x defines the x coordinate of the operand
  15948. * @param y defines the y coordinate of the operand
  15949. * @param z defines the z coordinate of the operand
  15950. * @returns the resulting Vector3
  15951. */
  15952. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15953. /**
  15954. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  15955. * @param x defines the x coordinate of the operand
  15956. * @param y defines the y coordinate of the operand
  15957. * @param z defines the z coordinate of the operand
  15958. * @param result defines the Vector3 object where to store the result
  15959. * @returns the current Vector3
  15960. */
  15961. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15962. /**
  15963. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15964. * @returns a new Vector3
  15965. */
  15966. negate(): Vector3;
  15967. /**
  15968. * Multiplies the Vector3 coordinates by the float "scale"
  15969. * @param scale defines the multiplier factor
  15970. * @returns the current updated Vector3
  15971. */
  15972. scaleInPlace(scale: number): Vector3;
  15973. /**
  15974. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15975. * @param scale defines the multiplier factor
  15976. * @returns a new Vector3
  15977. */
  15978. scale(scale: number): Vector3;
  15979. /**
  15980. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  15981. * @param scale defines the multiplier factor
  15982. * @param result defines the Vector3 object where to store the result
  15983. * @returns the current Vector3
  15984. */
  15985. scaleToRef(scale: number, result: Vector3): Vector3;
  15986. /**
  15987. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  15988. * @param scale defines the scale factor
  15989. * @param result defines the Vector3 object where to store the result
  15990. * @returns the unmodified current Vector3
  15991. */
  15992. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  15993. /**
  15994. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  15995. * @param otherVector defines the second operand
  15996. * @returns true if both vectors are equals
  15997. */
  15998. equals(otherVector: Vector3): boolean;
  15999. /**
  16000. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16001. * @param otherVector defines the second operand
  16002. * @param epsilon defines the minimal distance to define values as equals
  16003. * @returns true if both vectors are distant less than epsilon
  16004. */
  16005. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16006. /**
  16007. * Returns true if the current Vector3 coordinates equals the given floats
  16008. * @param x defines the x coordinate of the operand
  16009. * @param y defines the y coordinate of the operand
  16010. * @param z defines the z coordinate of the operand
  16011. * @returns true if both vectors are equals
  16012. */
  16013. equalsToFloats(x: number, y: number, z: number): boolean;
  16014. /**
  16015. * Multiplies the current Vector3 coordinates by the given ones
  16016. * @param otherVector defines the second operand
  16017. * @returns the current updated Vector3
  16018. */
  16019. multiplyInPlace(otherVector: Vector3): Vector3;
  16020. /**
  16021. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16022. * @param otherVector defines the second operand
  16023. * @returns the new Vector3
  16024. */
  16025. multiply(otherVector: Vector3): Vector3;
  16026. /**
  16027. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16028. * @param otherVector defines the second operand
  16029. * @param result defines the Vector3 object where to store the result
  16030. * @returns the current Vector3
  16031. */
  16032. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16033. /**
  16034. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16035. * @param x defines the x coordinate of the operand
  16036. * @param y defines the y coordinate of the operand
  16037. * @param z defines the z coordinate of the operand
  16038. * @returns the new Vector3
  16039. */
  16040. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16041. /**
  16042. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16043. * @param otherVector defines the second operand
  16044. * @returns the new Vector3
  16045. */
  16046. divide(otherVector: Vector3): Vector3;
  16047. /**
  16048. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16049. * @param otherVector defines the second operand
  16050. * @param result defines the Vector3 object where to store the result
  16051. * @returns the current Vector3
  16052. */
  16053. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16054. /**
  16055. * Divides the current Vector3 coordinates by the given ones.
  16056. * @param otherVector defines the second operand
  16057. * @returns the current updated Vector3
  16058. */
  16059. divideInPlace(otherVector: Vector3): Vector3;
  16060. /**
  16061. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16062. * @param other defines the second operand
  16063. * @returns the current updated Vector3
  16064. */
  16065. minimizeInPlace(other: Vector3): Vector3;
  16066. /**
  16067. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16068. * @param other defines the second operand
  16069. * @returns the current updated Vector3
  16070. */
  16071. maximizeInPlace(other: Vector3): Vector3;
  16072. /**
  16073. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16074. */
  16075. readonly isNonUniform: boolean;
  16076. /**
  16077. * Gets the length of the Vector3
  16078. * @returns the length of the Vecto3
  16079. */
  16080. length(): number;
  16081. /**
  16082. * Gets the squared length of the Vector3
  16083. * @returns squared length of the Vector3
  16084. */
  16085. lengthSquared(): number;
  16086. /**
  16087. * Normalize the current Vector3.
  16088. * Please note that this is an in place operation.
  16089. * @returns the current updated Vector3
  16090. */
  16091. normalize(): Vector3;
  16092. /**
  16093. * Normalize the current Vector3 to a new vector
  16094. * @returns the new Vector3
  16095. */
  16096. normalizeToNew(): Vector3;
  16097. /**
  16098. * Normalize the current Vector3 to the reference
  16099. * @param reference define the Vector3 to update
  16100. * @returns the updated Vector3
  16101. */
  16102. normalizeToRef(reference: Vector3): Vector3;
  16103. /**
  16104. * Creates a new Vector3 copied from the current Vector3
  16105. * @returns the new Vector3
  16106. */
  16107. clone(): Vector3;
  16108. /**
  16109. * Copies the given vector coordinates to the current Vector3 ones
  16110. * @param source defines the source Vector3
  16111. * @returns the current updated Vector3
  16112. */
  16113. copyFrom(source: Vector3): Vector3;
  16114. /**
  16115. * Copies the given floats to the current Vector3 coordinates
  16116. * @param x defines the x coordinate of the operand
  16117. * @param y defines the y coordinate of the operand
  16118. * @param z defines the z coordinate of the operand
  16119. * @returns the current updated Vector3
  16120. */
  16121. copyFromFloats(x: number, y: number, z: number): Vector3;
  16122. /**
  16123. * Copies the given floats to the current Vector3 coordinates
  16124. * @param x defines the x coordinate of the operand
  16125. * @param y defines the y coordinate of the operand
  16126. * @param z defines the z coordinate of the operand
  16127. * @returns the current updated Vector3
  16128. */
  16129. set(x: number, y: number, z: number): Vector3;
  16130. /**
  16131. * Get the clip factor between two vectors
  16132. * @param vector0 defines the first operand
  16133. * @param vector1 defines the second operand
  16134. * @param axis defines the axis to use
  16135. * @param size defines the size along the axis
  16136. * @returns the clip factor
  16137. */
  16138. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16139. /**
  16140. * Get angle between two vectors
  16141. * @param vector0 angle between vector0 and vector1
  16142. * @param vector1 angle between vector0 and vector1
  16143. * @param normal direction of the normal
  16144. * @return the angle between vector0 and vector1
  16145. */
  16146. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16147. /**
  16148. * Returns a new Vector3 set from the index "offset" of the given array
  16149. * @param array defines the source array
  16150. * @param offset defines the offset in the source array
  16151. * @returns the new Vector3
  16152. */
  16153. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16154. /**
  16155. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16156. * This function is deprecated. Use FromArray instead
  16157. * @param array defines the source array
  16158. * @param offset defines the offset in the source array
  16159. * @returns the new Vector3
  16160. */
  16161. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16162. /**
  16163. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16164. * @param array defines the source array
  16165. * @param offset defines the offset in the source array
  16166. * @param result defines the Vector3 where to store the result
  16167. */
  16168. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16169. /**
  16170. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16171. * This function is deprecated. Use FromArrayToRef instead.
  16172. * @param array defines the source array
  16173. * @param offset defines the offset in the source array
  16174. * @param result defines the Vector3 where to store the result
  16175. */
  16176. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16177. /**
  16178. * Sets the given vector "result" with the given floats.
  16179. * @param x defines the x coordinate of the source
  16180. * @param y defines the y coordinate of the source
  16181. * @param z defines the z coordinate of the source
  16182. * @param result defines the Vector3 where to store the result
  16183. */
  16184. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16185. /**
  16186. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16187. * @returns a new empty Vector3
  16188. */
  16189. static Zero(): Vector3;
  16190. /**
  16191. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16192. * @returns a new unit Vector3
  16193. */
  16194. static One(): Vector3;
  16195. /**
  16196. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16197. * @returns a new up Vector3
  16198. */
  16199. static Up(): Vector3;
  16200. /**
  16201. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16202. * @returns a new forward Vector3
  16203. */
  16204. static Forward(): Vector3;
  16205. /**
  16206. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16207. * @returns a new right Vector3
  16208. */
  16209. static Right(): Vector3;
  16210. /**
  16211. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16212. * @returns a new left Vector3
  16213. */
  16214. static Left(): Vector3;
  16215. /**
  16216. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16217. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16218. * @param vector defines the Vector3 to transform
  16219. * @param transformation defines the transformation matrix
  16220. * @returns the transformed Vector3
  16221. */
  16222. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16223. /**
  16224. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16225. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16226. * @param vector defines the Vector3 to transform
  16227. * @param transformation defines the transformation matrix
  16228. * @param result defines the Vector3 where to store the result
  16229. */
  16230. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16231. /**
  16232. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16233. * This method computes tranformed coordinates only, not transformed direction vectors
  16234. * @param x define the x coordinate of the source vector
  16235. * @param y define the y coordinate of the source vector
  16236. * @param z define the z coordinate of the source vector
  16237. * @param transformation defines the transformation matrix
  16238. * @param result defines the Vector3 where to store the result
  16239. */
  16240. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16241. /**
  16242. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16243. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16244. * @param vector defines the Vector3 to transform
  16245. * @param transformation defines the transformation matrix
  16246. * @returns the new Vector3
  16247. */
  16248. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16249. /**
  16250. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16251. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16252. * @param vector defines the Vector3 to transform
  16253. * @param transformation defines the transformation matrix
  16254. * @param result defines the Vector3 where to store the result
  16255. */
  16256. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16257. /**
  16258. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16259. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16260. * @param x define the x coordinate of the source vector
  16261. * @param y define the y coordinate of the source vector
  16262. * @param z define the z coordinate of the source vector
  16263. * @param transformation defines the transformation matrix
  16264. * @param result defines the Vector3 where to store the result
  16265. */
  16266. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16267. /**
  16268. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16269. * @param value1 defines the first control point
  16270. * @param value2 defines the second control point
  16271. * @param value3 defines the third control point
  16272. * @param value4 defines the fourth control point
  16273. * @param amount defines the amount on the spline to use
  16274. * @returns the new Vector3
  16275. */
  16276. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16277. /**
  16278. * 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"
  16279. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16280. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16281. * @param value defines the current value
  16282. * @param min defines the lower range value
  16283. * @param max defines the upper range value
  16284. * @returns the new Vector3
  16285. */
  16286. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16287. /**
  16288. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16289. * @param value1 defines the first control point
  16290. * @param tangent1 defines the first tangent vector
  16291. * @param value2 defines the second control point
  16292. * @param tangent2 defines the second tangent vector
  16293. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16294. * @returns the new Vector3
  16295. */
  16296. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16297. /**
  16298. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16299. * @param start defines the start value
  16300. * @param end defines the end value
  16301. * @param amount max defines amount between both (between 0 and 1)
  16302. * @returns the new Vector3
  16303. */
  16304. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16305. /**
  16306. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16307. * @param start defines the start value
  16308. * @param end defines the end value
  16309. * @param amount max defines amount between both (between 0 and 1)
  16310. * @param result defines the Vector3 where to store the result
  16311. */
  16312. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16313. /**
  16314. * Returns the dot product (float) between the vectors "left" and "right"
  16315. * @param left defines the left operand
  16316. * @param right defines the right operand
  16317. * @returns the dot product
  16318. */
  16319. static Dot(left: Vector3, right: Vector3): number;
  16320. /**
  16321. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16322. * The cross product is then orthogonal to both "left" and "right"
  16323. * @param left defines the left operand
  16324. * @param right defines the right operand
  16325. * @returns the cross product
  16326. */
  16327. static Cross(left: Vector3, right: Vector3): Vector3;
  16328. /**
  16329. * Sets the given vector "result" with the cross product of "left" and "right"
  16330. * The cross product is then orthogonal to both "left" and "right"
  16331. * @param left defines the left operand
  16332. * @param right defines the right operand
  16333. * @param result defines the Vector3 where to store the result
  16334. */
  16335. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16336. /**
  16337. * Returns a new Vector3 as the normalization of the given vector
  16338. * @param vector defines the Vector3 to normalize
  16339. * @returns the new Vector3
  16340. */
  16341. static Normalize(vector: Vector3): Vector3;
  16342. /**
  16343. * Sets the given vector "result" with the normalization of the given first vector
  16344. * @param vector defines the Vector3 to normalize
  16345. * @param result defines the Vector3 where to store the result
  16346. */
  16347. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16348. private static _viewportMatrixCache;
  16349. /**
  16350. * Project a Vector3 onto screen space
  16351. * @param vector defines the Vector3 to project
  16352. * @param world defines the world matrix to use
  16353. * @param transform defines the transform (view x projection) matrix to use
  16354. * @param viewport defines the screen viewport to use
  16355. * @returns the new Vector3
  16356. */
  16357. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16358. /**
  16359. * Unproject from screen space to object space
  16360. * @param source defines the screen space Vector3 to use
  16361. * @param viewportWidth defines the current width of the viewport
  16362. * @param viewportHeight defines the current height of the viewport
  16363. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16364. * @param transform defines the transform (view x projection) matrix to use
  16365. * @returns the new Vector3
  16366. */
  16367. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16368. /**
  16369. * Unproject from screen space to object space
  16370. * @param source defines the screen space Vector3 to use
  16371. * @param viewportWidth defines the current width of the viewport
  16372. * @param viewportHeight defines the current height of the viewport
  16373. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16374. * @param view defines the view matrix to use
  16375. * @param projection defines the projection matrix to use
  16376. * @returns the new Vector3
  16377. */
  16378. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16379. /**
  16380. * Unproject from screen space to object space
  16381. * @param source defines the screen space Vector3 to use
  16382. * @param viewportWidth defines the current width of the viewport
  16383. * @param viewportHeight defines the current height of the viewport
  16384. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16385. * @param view defines the view matrix to use
  16386. * @param projection defines the projection matrix to use
  16387. * @param result defines the Vector3 where to store the result
  16388. */
  16389. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16390. /**
  16391. * Unproject from screen space to object space
  16392. * @param sourceX defines the screen space x coordinate to use
  16393. * @param sourceY defines the screen space y coordinate to use
  16394. * @param sourceZ defines the screen space z coordinate to use
  16395. * @param viewportWidth defines the current width of the viewport
  16396. * @param viewportHeight defines the current height of the viewport
  16397. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16398. * @param view defines the view matrix to use
  16399. * @param projection defines the projection matrix to use
  16400. * @param result defines the Vector3 where to store the result
  16401. */
  16402. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16403. /**
  16404. * Gets the minimal coordinate values between two Vector3
  16405. * @param left defines the first operand
  16406. * @param right defines the second operand
  16407. * @returns the new Vector3
  16408. */
  16409. static Minimize(left: Vector3, right: Vector3): Vector3;
  16410. /**
  16411. * Gets the maximal coordinate values between two Vector3
  16412. * @param left defines the first operand
  16413. * @param right defines the second operand
  16414. * @returns the new Vector3
  16415. */
  16416. static Maximize(left: Vector3, right: Vector3): Vector3;
  16417. /**
  16418. * Returns the distance between the vectors "value1" and "value2"
  16419. * @param value1 defines the first operand
  16420. * @param value2 defines the second operand
  16421. * @returns the distance
  16422. */
  16423. static Distance(value1: Vector3, value2: Vector3): number;
  16424. /**
  16425. * Returns the squared distance between the vectors "value1" and "value2"
  16426. * @param value1 defines the first operand
  16427. * @param value2 defines the second operand
  16428. * @returns the squared distance
  16429. */
  16430. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16431. /**
  16432. * Returns a new Vector3 located at the center between "value1" and "value2"
  16433. * @param value1 defines the first operand
  16434. * @param value2 defines the second operand
  16435. * @returns the new Vector3
  16436. */
  16437. static Center(value1: Vector3, value2: Vector3): Vector3;
  16438. /**
  16439. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16440. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16441. * to something in order to rotate it from its local system to the given target system
  16442. * Note: axis1, axis2 and axis3 are normalized during this operation
  16443. * @param axis1 defines the first axis
  16444. * @param axis2 defines the second axis
  16445. * @param axis3 defines the third axis
  16446. * @returns a new Vector3
  16447. */
  16448. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16449. /**
  16450. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16451. * @param axis1 defines the first axis
  16452. * @param axis2 defines the second axis
  16453. * @param axis3 defines the third axis
  16454. * @param ref defines the Vector3 where to store the result
  16455. */
  16456. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16457. }
  16458. class Vector4 {
  16459. x: number;
  16460. y: number;
  16461. z: number;
  16462. w: number;
  16463. /**
  16464. * Creates a Vector4 object from the given floats.
  16465. */
  16466. constructor(x: number, y: number, z: number, w: number);
  16467. /**
  16468. * Returns the string with the Vector4 coordinates.
  16469. */
  16470. toString(): string;
  16471. /**
  16472. * Returns the string "Vector4".
  16473. */
  16474. getClassName(): string;
  16475. /**
  16476. * Returns the Vector4 hash code.
  16477. */
  16478. getHashCode(): number;
  16479. /**
  16480. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16481. */
  16482. asArray(): number[];
  16483. /**
  16484. * Populates the given array from the given index with the Vector4 coordinates.
  16485. * Returns the Vector4.
  16486. */
  16487. toArray(array: FloatArray, index?: number): Vector4;
  16488. /**
  16489. * Adds the given vector to the current Vector4.
  16490. * Returns the updated Vector4.
  16491. */
  16492. addInPlace(otherVector: Vector4): Vector4;
  16493. /**
  16494. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16495. */
  16496. add(otherVector: Vector4): Vector4;
  16497. /**
  16498. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16499. * Returns the current Vector4.
  16500. */
  16501. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16502. /**
  16503. * Subtract in place the given vector from the current Vector4.
  16504. * Returns the updated Vector4.
  16505. */
  16506. subtractInPlace(otherVector: Vector4): Vector4;
  16507. /**
  16508. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16509. */
  16510. subtract(otherVector: Vector4): Vector4;
  16511. /**
  16512. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16513. * Returns the current Vector4.
  16514. */
  16515. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16516. /**
  16517. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16518. */
  16519. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16520. /**
  16521. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16522. * Returns the current Vector4.
  16523. */
  16524. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16525. /**
  16526. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16527. */
  16528. negate(): Vector4;
  16529. /**
  16530. * Multiplies the current Vector4 coordinates by scale (float).
  16531. * Returns the updated Vector4.
  16532. */
  16533. scaleInPlace(scale: number): Vector4;
  16534. /**
  16535. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16536. */
  16537. scale(scale: number): Vector4;
  16538. /**
  16539. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16540. * Returns the current Vector4.
  16541. */
  16542. scaleToRef(scale: number, result: Vector4): Vector4;
  16543. /**
  16544. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16545. * @param scale defines the scale factor
  16546. * @param result defines the Vector4 object where to store the result
  16547. * @returns the unmodified current Vector4
  16548. */
  16549. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16550. /**
  16551. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16552. */
  16553. equals(otherVector: Vector4): boolean;
  16554. /**
  16555. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16556. */
  16557. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16558. /**
  16559. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16560. */
  16561. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16562. /**
  16563. * Multiplies in place the current Vector4 by the given one.
  16564. * Returns the updated Vector4.
  16565. */
  16566. multiplyInPlace(otherVector: Vector4): Vector4;
  16567. /**
  16568. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16569. */
  16570. multiply(otherVector: Vector4): Vector4;
  16571. /**
  16572. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16573. * Returns the current Vector4.
  16574. */
  16575. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16576. /**
  16577. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16578. */
  16579. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16580. /**
  16581. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16582. */
  16583. divide(otherVector: Vector4): Vector4;
  16584. /**
  16585. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16586. * Returns the current Vector4.
  16587. */
  16588. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16589. /**
  16590. * Divides the current Vector3 coordinates by the given ones.
  16591. * @returns the updated Vector3.
  16592. */
  16593. divideInPlace(otherVector: Vector4): Vector4;
  16594. /**
  16595. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16596. * @param other defines the second operand
  16597. * @returns the current updated Vector4
  16598. */
  16599. minimizeInPlace(other: Vector4): Vector4;
  16600. /**
  16601. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16602. * @param other defines the second operand
  16603. * @returns the current updated Vector4
  16604. */
  16605. maximizeInPlace(other: Vector4): Vector4;
  16606. /**
  16607. * Returns the Vector4 length (float).
  16608. */
  16609. length(): number;
  16610. /**
  16611. * Returns the Vector4 squared length (float).
  16612. */
  16613. lengthSquared(): number;
  16614. /**
  16615. * Normalizes in place the Vector4.
  16616. * Returns the updated Vector4.
  16617. */
  16618. normalize(): Vector4;
  16619. /**
  16620. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16621. */
  16622. toVector3(): Vector3;
  16623. /**
  16624. * Returns a new Vector4 copied from the current one.
  16625. */
  16626. clone(): Vector4;
  16627. /**
  16628. * Updates the current Vector4 with the given one coordinates.
  16629. * Returns the updated Vector4.
  16630. */
  16631. copyFrom(source: Vector4): Vector4;
  16632. /**
  16633. * Updates the current Vector4 coordinates with the given floats.
  16634. * Returns the updated Vector4.
  16635. */
  16636. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16637. /**
  16638. * Updates the current Vector4 coordinates with the given floats.
  16639. * Returns the updated Vector4.
  16640. */
  16641. set(x: number, y: number, z: number, w: number): Vector4;
  16642. /**
  16643. * Returns a new Vector4 set from the starting index of the given array.
  16644. */
  16645. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16646. /**
  16647. * Updates the given vector "result" from the starting index of the given array.
  16648. */
  16649. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16650. /**
  16651. * Updates the given vector "result" from the starting index of the given Float32Array.
  16652. */
  16653. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16654. /**
  16655. * Updates the given vector "result" coordinates from the given floats.
  16656. */
  16657. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16658. /**
  16659. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16660. */
  16661. static Zero(): Vector4;
  16662. /**
  16663. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16664. */
  16665. static One(): Vector4;
  16666. /**
  16667. * Returns a new normalized Vector4 from the given one.
  16668. */
  16669. static Normalize(vector: Vector4): Vector4;
  16670. /**
  16671. * Updates the given vector "result" from the normalization of the given one.
  16672. */
  16673. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16674. static Minimize(left: Vector4, right: Vector4): Vector4;
  16675. static Maximize(left: Vector4, right: Vector4): Vector4;
  16676. /**
  16677. * Returns the distance (float) between the vectors "value1" and "value2".
  16678. */
  16679. static Distance(value1: Vector4, value2: Vector4): number;
  16680. /**
  16681. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16682. */
  16683. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16684. /**
  16685. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16686. */
  16687. static Center(value1: Vector4, value2: Vector4): Vector4;
  16688. /**
  16689. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16690. * This methods computes transformed normalized direction vectors only.
  16691. */
  16692. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16693. /**
  16694. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16695. * This methods computes transformed normalized direction vectors only.
  16696. */
  16697. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16698. /**
  16699. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16700. * This methods computes transformed normalized direction vectors only.
  16701. */
  16702. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16703. }
  16704. interface ISize {
  16705. width: number;
  16706. height: number;
  16707. }
  16708. class Size implements ISize {
  16709. width: number;
  16710. height: number;
  16711. /**
  16712. * Creates a Size object from the given width and height (floats).
  16713. */
  16714. constructor(width: number, height: number);
  16715. toString(): string;
  16716. /**
  16717. * Returns the string "Size"
  16718. */
  16719. getClassName(): string;
  16720. /**
  16721. * Returns the Size hash code.
  16722. */
  16723. getHashCode(): number;
  16724. /**
  16725. * Updates the current size from the given one.
  16726. * Returns the updated Size.
  16727. */
  16728. copyFrom(src: Size): void;
  16729. /**
  16730. * Updates in place the current Size from the given floats.
  16731. * Returns the updated Size.
  16732. */
  16733. copyFromFloats(width: number, height: number): Size;
  16734. /**
  16735. * Updates in place the current Size from the given floats.
  16736. * Returns the updated Size.
  16737. */
  16738. set(width: number, height: number): Size;
  16739. /**
  16740. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16741. */
  16742. multiplyByFloats(w: number, h: number): Size;
  16743. /**
  16744. * Returns a new Size copied from the given one.
  16745. */
  16746. clone(): Size;
  16747. /**
  16748. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16749. */
  16750. equals(other: Size): boolean;
  16751. /**
  16752. * Returns the surface of the Size : width * height (float).
  16753. */
  16754. readonly surface: number;
  16755. /**
  16756. * Returns a new Size set to (0.0, 0.0)
  16757. */
  16758. static Zero(): Size;
  16759. /**
  16760. * Returns a new Size set as the addition result of the current Size and the given one.
  16761. */
  16762. add(otherSize: Size): Size;
  16763. /**
  16764. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16765. */
  16766. subtract(otherSize: Size): Size;
  16767. /**
  16768. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16769. */
  16770. static Lerp(start: Size, end: Size, amount: number): Size;
  16771. }
  16772. /**
  16773. * Class used to store quaternion data
  16774. * @see https://en.wikipedia.org/wiki/Quaternion
  16775. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16776. */
  16777. class Quaternion {
  16778. /** defines the first component (0 by default) */
  16779. x: number;
  16780. /** defines the second component (0 by default) */
  16781. y: number;
  16782. /** defines the third component (0 by default) */
  16783. z: number;
  16784. /** defines the fourth component (1.0 by default) */
  16785. w: number;
  16786. /**
  16787. * Creates a new Quaternion from the given floats
  16788. * @param x defines the first component (0 by default)
  16789. * @param y defines the second component (0 by default)
  16790. * @param z defines the third component (0 by default)
  16791. * @param w defines the fourth component (1.0 by default)
  16792. */
  16793. constructor(
  16794. /** defines the first component (0 by default) */
  16795. x?: number,
  16796. /** defines the second component (0 by default) */
  16797. y?: number,
  16798. /** defines the third component (0 by default) */
  16799. z?: number,
  16800. /** defines the fourth component (1.0 by default) */
  16801. w?: number);
  16802. /**
  16803. * Gets a string representation for the current quaternion
  16804. * @returns a string with the Quaternion coordinates
  16805. */
  16806. toString(): string;
  16807. /**
  16808. * Gets the class name of the quaternion
  16809. * @returns the string "Quaternion"
  16810. */
  16811. getClassName(): string;
  16812. /**
  16813. * Gets a hash code for this quaternion
  16814. * @returns the quaternion hash code
  16815. */
  16816. getHashCode(): number;
  16817. /**
  16818. * Copy the quaternion to an array
  16819. * @returns a new array populated with 4 elements from the quaternion coordinates
  16820. */
  16821. asArray(): number[];
  16822. /**
  16823. * Check if two quaternions are equals
  16824. * @param otherQuaternion defines the second operand
  16825. * @return true if the current quaternion and the given one coordinates are strictly equals
  16826. */
  16827. equals(otherQuaternion: Quaternion): boolean;
  16828. /**
  16829. * Clone the current quaternion
  16830. * @returns a new quaternion copied from the current one
  16831. */
  16832. clone(): Quaternion;
  16833. /**
  16834. * Copy a quaternion to the current one
  16835. * @param other defines the other quaternion
  16836. * @returns the updated current quaternion
  16837. */
  16838. copyFrom(other: Quaternion): Quaternion;
  16839. /**
  16840. * Updates the current quaternion with the given float coordinates
  16841. * @param x defines the x coordinate
  16842. * @param y defines the y coordinate
  16843. * @param z defines the z coordinate
  16844. * @param w defines the w coordinate
  16845. * @returns the updated current quaternion
  16846. */
  16847. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16848. /**
  16849. * Updates the current quaternion from the given float coordinates
  16850. * @param x defines the x coordinate
  16851. * @param y defines the y coordinate
  16852. * @param z defines the z coordinate
  16853. * @param w defines the w coordinate
  16854. * @returns the updated current quaternion
  16855. */
  16856. set(x: number, y: number, z: number, w: number): Quaternion;
  16857. /**
  16858. * Adds two quaternions
  16859. * @param other defines the second operand
  16860. * @returns a new quaternion as the addition result of the given one and the current quaternion
  16861. */
  16862. add(other: Quaternion): Quaternion;
  16863. /**
  16864. * Add a quaternion to the current one
  16865. * @param other defines the quaternion to add
  16866. * @returns the current quaternion
  16867. */
  16868. addInPlace(other: Quaternion): Quaternion;
  16869. /**
  16870. * Subtract two quaternions
  16871. * @param other defines the second operand
  16872. * @returns a new quaternion as the subtraction result of the given one from the current one
  16873. */
  16874. subtract(other: Quaternion): Quaternion;
  16875. /**
  16876. * Multiplies the current quaternion by a scale factor
  16877. * @param value defines the scale factor
  16878. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  16879. */
  16880. scale(value: number): Quaternion;
  16881. /**
  16882. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  16883. * @param scale defines the scale factor
  16884. * @param result defines the Quaternion object where to store the result
  16885. * @returns the unmodified current quaternion
  16886. */
  16887. scaleToRef(scale: number, result: Quaternion): Quaternion;
  16888. /**
  16889. * Multiplies in place the current quaternion by a scale factor
  16890. * @param value defines the scale factor
  16891. * @returns the current modified quaternion
  16892. */
  16893. scaleInPlace(value: number): Quaternion;
  16894. /**
  16895. * Scale the current quaternion values by a factor and add the result to a given quaternion
  16896. * @param scale defines the scale factor
  16897. * @param result defines the Quaternion object where to store the result
  16898. * @returns the unmodified current quaternion
  16899. */
  16900. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  16901. /**
  16902. * Multiplies two quaternions
  16903. * @param q1 defines the second operand
  16904. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  16905. */
  16906. multiply(q1: Quaternion): Quaternion;
  16907. /**
  16908. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  16909. * @param q1 defines the second operand
  16910. * @param result defines the target quaternion
  16911. * @returns the current quaternion
  16912. */
  16913. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16914. /**
  16915. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  16916. * @param q1 defines the second operand
  16917. * @returns the currentupdated quaternion
  16918. */
  16919. multiplyInPlace(q1: Quaternion): Quaternion;
  16920. /**
  16921. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  16922. * @param ref defines the target quaternion
  16923. * @returns the current quaternion
  16924. */
  16925. conjugateToRef(ref: Quaternion): Quaternion;
  16926. /**
  16927. * Conjugates in place (1-q) the current quaternion
  16928. * @returns the current updated quaternion
  16929. */
  16930. conjugateInPlace(): Quaternion;
  16931. /**
  16932. * Conjugates in place (1-q) the current quaternion
  16933. * @returns a new quaternion
  16934. */
  16935. conjugate(): Quaternion;
  16936. /**
  16937. * Gets length of current quaternion
  16938. * @returns the quaternion length (float)
  16939. */
  16940. length(): number;
  16941. /**
  16942. * Normalize in place the current quaternion
  16943. * @returns the current updated quaternion
  16944. */
  16945. normalize(): Quaternion;
  16946. /**
  16947. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  16948. * @param order is a reserved parameter and is ignore for now
  16949. * @returns a new Vector3 containing the Euler angles
  16950. */
  16951. toEulerAngles(order?: string): Vector3;
  16952. /**
  16953. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  16954. * @param result defines the vector which will be filled with the Euler angles
  16955. * @param order is a reserved parameter and is ignore for now
  16956. * @returns the current unchanged quaternion
  16957. */
  16958. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16959. /**
  16960. * Updates the given rotation matrix with the current quaternion values
  16961. * @param result defines the target matrix
  16962. * @returns the current unchanged quaternion
  16963. */
  16964. toRotationMatrix(result: Matrix): Quaternion;
  16965. /**
  16966. * Updates the current quaternion from the given rotation matrix values
  16967. * @param matrix defines the source matrix
  16968. * @returns the current updated quaternion
  16969. */
  16970. fromRotationMatrix(matrix: Matrix): Quaternion;
  16971. /**
  16972. * Creates a new quaternion from a rotation matrix
  16973. * @param matrix defines the source matrix
  16974. * @returns a new quaternion created from the given rotation matrix values
  16975. */
  16976. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16977. /**
  16978. * Updates the given quaternion with the given rotation matrix values
  16979. * @param matrix defines the source matrix
  16980. * @param result defines the target quaternion
  16981. */
  16982. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16983. /**
  16984. * Returns the dot product (float) between the quaternions "left" and "right"
  16985. * @param left defines the left operand
  16986. * @param right defines the right operand
  16987. * @returns the dot product
  16988. */
  16989. static Dot(left: Quaternion, right: Quaternion): number;
  16990. /**
  16991. * Checks if the two quaternions are close to each other
  16992. * @param quat0 defines the first quaternion to check
  16993. * @param quat1 defines the second quaternion to check
  16994. * @returns true if the two quaternions are close to each other
  16995. */
  16996. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  16997. /**
  16998. * Creates an empty quaternion
  16999. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17000. */
  17001. static Zero(): Quaternion;
  17002. /**
  17003. * Inverse a given quaternion
  17004. * @param q defines the source quaternion
  17005. * @returns a new quaternion as the inverted current quaternion
  17006. */
  17007. static Inverse(q: Quaternion): Quaternion;
  17008. /**
  17009. * Creates an identity quaternion
  17010. * @returns the identity quaternion
  17011. */
  17012. static Identity(): Quaternion;
  17013. /**
  17014. * Gets a boolean indicating if the given quaternion is identity
  17015. * @param quaternion defines the quaternion to check
  17016. * @returns true if the quaternion is identity
  17017. */
  17018. static IsIdentity(quaternion: Quaternion): boolean;
  17019. /**
  17020. * Creates a quaternion from a rotation around an axis
  17021. * @param axis defines the axis to use
  17022. * @param angle defines the angle to use
  17023. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17024. */
  17025. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17026. /**
  17027. * Creates a rotation around an axis and stores it into the given quaternion
  17028. * @param axis defines the axis to use
  17029. * @param angle defines the angle to use
  17030. * @param result defines the target quaternion
  17031. * @returns the target quaternion
  17032. */
  17033. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17034. /**
  17035. * Creates a new quaternion from data stored into an array
  17036. * @param array defines the data source
  17037. * @param offset defines the offset in the source array where the data starts
  17038. * @returns a new quaternion
  17039. */
  17040. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17041. /**
  17042. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17043. * @param yaw defines the rotation around Y axis
  17044. * @param pitch defines the rotation around X axis
  17045. * @param roll defines the rotation around Z axis
  17046. * @returns the new quaternion
  17047. */
  17048. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17049. /**
  17050. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17051. * @param yaw defines the rotation around Y axis
  17052. * @param pitch defines the rotation around X axis
  17053. * @param roll defines the rotation around Z axis
  17054. * @param result defines the target quaternion
  17055. */
  17056. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17057. /**
  17058. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17059. * @param alpha defines the rotation around first axis
  17060. * @param beta defines the rotation around second axis
  17061. * @param gamma defines the rotation around third axis
  17062. * @returns the new quaternion
  17063. */
  17064. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17065. /**
  17066. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17067. * @param alpha defines the rotation around first axis
  17068. * @param beta defines the rotation around second axis
  17069. * @param gamma defines the rotation around third axis
  17070. * @param result defines the target quaternion
  17071. */
  17072. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17073. /**
  17074. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  17075. * @param axis1 defines the first axis
  17076. * @param axis2 defines the second axis
  17077. * @param axis3 defines the third axis
  17078. * @returns the new quaternion
  17079. */
  17080. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17081. /**
  17082. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  17083. * @param axis1 defines the first axis
  17084. * @param axis2 defines the second axis
  17085. * @param axis3 defines the third axis
  17086. * @param ref defines the target quaternion
  17087. */
  17088. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17089. /**
  17090. * Interpolates between two quaternions
  17091. * @param left defines first quaternion
  17092. * @param right defines second quaternion
  17093. * @param amount defines the gradient to use
  17094. * @returns the new interpolated quaternion
  17095. */
  17096. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17097. /**
  17098. * Interpolates between two quaternions and stores it into a target quaternion
  17099. * @param left defines first quaternion
  17100. * @param right defines second quaternion
  17101. * @param amount defines the gradient to use
  17102. * @param result defines the target quaternion
  17103. */
  17104. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17105. /**
  17106. * Interpolate between two quaternions using Hermite interpolation
  17107. * @param value1 defines first quaternion
  17108. * @param tangent1 defines the incoming tangent
  17109. * @param value2 defines second quaternion
  17110. * @param tangent2 defines the outgoing tangent
  17111. * @param amount defines the target quaternion
  17112. * @returns the new interpolated quaternion
  17113. */
  17114. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17115. }
  17116. /**
  17117. * Class used to store matrix data (4x4)
  17118. */
  17119. class Matrix {
  17120. private static _tempQuaternion;
  17121. private static _xAxis;
  17122. private static _yAxis;
  17123. private static _zAxis;
  17124. private static _updateFlagSeed;
  17125. private static _identityReadOnly;
  17126. private _isIdentity;
  17127. private _isIdentityDirty;
  17128. /**
  17129. * Gets the update flag of the matrix which is an unique number for the matrix.
  17130. * It will be incremented every time the matrix data change.
  17131. * You can use it to speed the comparison between two versions of the same matrix.
  17132. */
  17133. updateFlag: number;
  17134. /**
  17135. * Gets or sets the internal data of the matrix
  17136. */
  17137. m: Float32Array;
  17138. /** @hidden */
  17139. _markAsUpdated(): void;
  17140. /**
  17141. * Creates an empty matrix (filled with zeros)
  17142. */
  17143. constructor();
  17144. /**
  17145. * Check if the current matrix is indentity
  17146. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17147. * @returns true is the matrix is the identity matrix
  17148. */
  17149. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17150. /**
  17151. * Gets the determinant of the matrix
  17152. * @returns the matrix determinant
  17153. */
  17154. determinant(): number;
  17155. /**
  17156. * Returns the matrix as a Float32Array
  17157. * @returns the matrix underlying array
  17158. */
  17159. toArray(): Float32Array;
  17160. /**
  17161. * Returns the matrix as a Float32Array
  17162. * @returns the matrix underlying array.
  17163. */
  17164. asArray(): Float32Array;
  17165. /**
  17166. * Inverts the current matrix in place
  17167. * @returns the current inverted matrix
  17168. */
  17169. invert(): Matrix;
  17170. /**
  17171. * Sets all the matrix elements to zero
  17172. * @returns the current matrix
  17173. */
  17174. reset(): Matrix;
  17175. /**
  17176. * Adds the current matrix with a second one
  17177. * @param other defines the matrix to add
  17178. * @returns a new matrix as the addition of the current matrix and the given one
  17179. */
  17180. add(other: Matrix): Matrix;
  17181. /**
  17182. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17183. * @param other defines the matrix to add
  17184. * @param result defines the target matrix
  17185. * @returns the current matrix
  17186. */
  17187. addToRef(other: Matrix, result: Matrix): Matrix;
  17188. /**
  17189. * Adds in place the given matrix to the current matrix
  17190. * @param other defines the second operand
  17191. * @returns the current updated matrix
  17192. */
  17193. addToSelf(other: Matrix): Matrix;
  17194. /**
  17195. * Sets the given matrix to the current inverted Matrix
  17196. * @param other defines the target matrix
  17197. * @returns the unmodified current matrix
  17198. */
  17199. invertToRef(other: Matrix): Matrix;
  17200. /**
  17201. * Inserts the translation vector (using 3 floats) in the current matrix
  17202. * @param x defines the 1st component of the translation
  17203. * @param y defines the 2nd component of the translation
  17204. * @param z defines the 3rd component of the translation
  17205. * @returns the current updated matrix
  17206. */
  17207. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17208. /**
  17209. * Inserts the translation vector in the current matrix
  17210. * @param vector3 defines the translation to insert
  17211. * @returns the current updated matrix
  17212. */
  17213. setTranslation(vector3: Vector3): Matrix;
  17214. /**
  17215. * Gets the translation value of the current matrix
  17216. * @returns a new Vector3 as the extracted translation from the matrix
  17217. */
  17218. getTranslation(): Vector3;
  17219. /**
  17220. * Fill a Vector3 with the extracted translation from the matrix
  17221. * @param result defines the Vector3 where to store the translation
  17222. * @returns the current matrix
  17223. */
  17224. getTranslationToRef(result: Vector3): Matrix;
  17225. /**
  17226. * Remove rotation and scaling part from the matrix
  17227. * @returns the updated matrix
  17228. */
  17229. removeRotationAndScaling(): Matrix;
  17230. /**
  17231. * Multiply two matrices
  17232. * @param other defines the second operand
  17233. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17234. */
  17235. multiply(other: Matrix): Matrix;
  17236. /**
  17237. * Copy the current matrix from the given one
  17238. * @param other defines the source matrix
  17239. * @returns the current updated matrix
  17240. */
  17241. copyFrom(other: Matrix): Matrix;
  17242. /**
  17243. * Populates the given array from the starting index with the current matrix values
  17244. * @param array defines the target array
  17245. * @param offset defines the offset in the target array where to start storing values
  17246. * @returns the current matrix
  17247. */
  17248. copyToArray(array: Float32Array, offset?: number): Matrix;
  17249. /**
  17250. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17251. * @param other defines the second operand
  17252. * @param result defines the matrix where to store the multiplication
  17253. * @returns the current matrix
  17254. */
  17255. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17256. /**
  17257. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17258. * @param other defines the second operand
  17259. * @param result defines the array where to store the multiplication
  17260. * @param offset defines the offset in the target array where to start storing values
  17261. * @returns the current matrix
  17262. */
  17263. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17264. /**
  17265. * Check equality between this matrix and a second one
  17266. * @param value defines the second matrix to compare
  17267. * @returns true is the current matrix and the given one values are strictly equal
  17268. */
  17269. equals(value: Matrix): boolean;
  17270. /**
  17271. * Clone the current matrix
  17272. * @returns a new matrix from the current matrix
  17273. */
  17274. clone(): Matrix;
  17275. /**
  17276. * Returns the name of the current matrix class
  17277. * @returns the string "Matrix"
  17278. */
  17279. getClassName(): string;
  17280. /**
  17281. * Gets the hash code of the current matrix
  17282. * @returns the hash code
  17283. */
  17284. getHashCode(): number;
  17285. /**
  17286. * Decomposes the current Matrix into a translation, rotation and scaling components
  17287. * @param scale defines the scale vector3 given as a reference to update
  17288. * @param rotation defines the rotation quaternion given as a reference to update
  17289. * @param translation defines the translation vector3 given as a reference to update
  17290. * @returns true if operation was successful
  17291. */
  17292. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17293. /**
  17294. * Gets specific row of the matrix
  17295. * @param index defines the number of the row to get
  17296. * @returns the index-th row of the current matrix as a new Vector4
  17297. */
  17298. getRow(index: number): Nullable<Vector4>;
  17299. /**
  17300. * Sets the index-th row of the current matrix to the vector4 values
  17301. * @param index defines the number of the row to set
  17302. * @param row defines the target vector4
  17303. * @returns the updated current matrix
  17304. */
  17305. setRow(index: number, row: Vector4): Matrix;
  17306. /**
  17307. * Compute the transpose of the matrix
  17308. * @returns the new transposed matrix
  17309. */
  17310. transpose(): Matrix;
  17311. /**
  17312. * Compute the transpose of the matrix and store it in a given matrix
  17313. * @param result defines the target matrix
  17314. * @returns the current matrix
  17315. */
  17316. transposeToRef(result: Matrix): Matrix;
  17317. /**
  17318. * Sets the index-th row of the current matrix with the given 4 x float values
  17319. * @param index defines the row index
  17320. * @param x defines the x component to set
  17321. * @param y defines the y component to set
  17322. * @param z defines the z component to set
  17323. * @param w defines the w component to set
  17324. * @returns the updated current matrix
  17325. */
  17326. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17327. /**
  17328. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17329. * @param scale defines the scale factor
  17330. * @returns a new matrix
  17331. */
  17332. scale(scale: number): Matrix;
  17333. /**
  17334. * Scale the current matrix values by a factor to a given result matrix
  17335. * @param scale defines the scale factor
  17336. * @param result defines the matrix to store the result
  17337. * @returns the current matrix
  17338. */
  17339. scaleToRef(scale: number, result: Matrix): Matrix;
  17340. /**
  17341. * Scale the current matrix values by a factor and add the result to a given matrix
  17342. * @param scale defines the scale factor
  17343. * @param result defines the Matrix to store the result
  17344. * @returns the current matrix
  17345. */
  17346. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17347. /**
  17348. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17349. * @param ref matrix to store the result
  17350. */
  17351. toNormalMatrix(ref: Matrix): void;
  17352. /**
  17353. * Gets only rotation part of the current matrix
  17354. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17355. */
  17356. getRotationMatrix(): Matrix;
  17357. /**
  17358. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17359. * @param result defines the target matrix to store data to
  17360. * @returns the current matrix
  17361. */
  17362. getRotationMatrixToRef(result: Matrix): Matrix;
  17363. /**
  17364. * Creates a matrix from an array
  17365. * @param array defines the source array
  17366. * @param offset defines an offset in the source array
  17367. * @returns a new Matrix set from the starting index of the given array
  17368. */
  17369. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17370. /**
  17371. * Copy the content of an array into a given matrix
  17372. * @param array defines the source array
  17373. * @param offset defines an offset in the source array
  17374. * @param result defines the target matrix
  17375. */
  17376. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17377. /**
  17378. * Stores an array into a matrix after having multiplied each component by a given factor
  17379. * @param array defines the source array
  17380. * @param offset defines the offset in the source array
  17381. * @param scale defines the scaling factor
  17382. * @param result defines the target matrix
  17383. */
  17384. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17385. /**
  17386. * Stores a list of values (16) inside a given matrix
  17387. * @param initialM11 defines 1st value of 1st row
  17388. * @param initialM12 defines 2nd value of 1st row
  17389. * @param initialM13 defines 3rd value of 1st row
  17390. * @param initialM14 defines 4th value of 1st row
  17391. * @param initialM21 defines 1st value of 2nd row
  17392. * @param initialM22 defines 2nd value of 2nd row
  17393. * @param initialM23 defines 3rd value of 2nd row
  17394. * @param initialM24 defines 4th value of 2nd row
  17395. * @param initialM31 defines 1st value of 3rd row
  17396. * @param initialM32 defines 2nd value of 3rd row
  17397. * @param initialM33 defines 3rd value of 3rd row
  17398. * @param initialM34 defines 4th value of 3rd row
  17399. * @param initialM41 defines 1st value of 4th row
  17400. * @param initialM42 defines 2nd value of 4th row
  17401. * @param initialM43 defines 3rd value of 4th row
  17402. * @param initialM44 defines 4th value of 4th row
  17403. * @param result defines the target matrix
  17404. */
  17405. 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;
  17406. /**
  17407. * Gets an identity matrix that must not be updated
  17408. */
  17409. static readonly IdentityReadOnly: Matrix;
  17410. /**
  17411. * Creates new matrix from a list of values (16)
  17412. * @param initialM11 defines 1st value of 1st row
  17413. * @param initialM12 defines 2nd value of 1st row
  17414. * @param initialM13 defines 3rd value of 1st row
  17415. * @param initialM14 defines 4th value of 1st row
  17416. * @param initialM21 defines 1st value of 2nd row
  17417. * @param initialM22 defines 2nd value of 2nd row
  17418. * @param initialM23 defines 3rd value of 2nd row
  17419. * @param initialM24 defines 4th value of 2nd row
  17420. * @param initialM31 defines 1st value of 3rd row
  17421. * @param initialM32 defines 2nd value of 3rd row
  17422. * @param initialM33 defines 3rd value of 3rd row
  17423. * @param initialM34 defines 4th value of 3rd row
  17424. * @param initialM41 defines 1st value of 4th row
  17425. * @param initialM42 defines 2nd value of 4th row
  17426. * @param initialM43 defines 3rd value of 4th row
  17427. * @param initialM44 defines 4th value of 4th row
  17428. * @returns the new matrix
  17429. */
  17430. 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;
  17431. /**
  17432. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17433. * @param scale defines the scale vector3
  17434. * @param rotation defines the rotation quaternion
  17435. * @param translation defines the translation vector3
  17436. * @returns a new matrix
  17437. */
  17438. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17439. /**
  17440. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17441. * @param scale defines the scale vector3
  17442. * @param rotation defines the rotation quaternion
  17443. * @param translation defines the translation vector3
  17444. * @param result defines the target matrix
  17445. */
  17446. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17447. /**
  17448. * Creates a new identity matrix
  17449. * @returns a new identity matrix
  17450. */
  17451. static Identity(): Matrix;
  17452. /**
  17453. * Creates a new identity matrix and stores the result in a given matrix
  17454. * @param result defines the target matrix
  17455. */
  17456. static IdentityToRef(result: Matrix): void;
  17457. /**
  17458. * Creates a new zero matrix
  17459. * @returns a new zero matrix
  17460. */
  17461. static Zero(): Matrix;
  17462. /**
  17463. * Creates a new rotation matrix for "angle" radians around the X axis
  17464. * @param angle defines the angle (in radians) to use
  17465. * @return the new matrix
  17466. */
  17467. static RotationX(angle: number): Matrix;
  17468. /**
  17469. * Creates a new matrix as the invert of a given matrix
  17470. * @param source defines the source matrix
  17471. * @returns the new matrix
  17472. */
  17473. static Invert(source: Matrix): Matrix;
  17474. /**
  17475. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17476. * @param angle defines the angle (in radians) to use
  17477. * @param result defines the target matrix
  17478. */
  17479. static RotationXToRef(angle: number, result: Matrix): void;
  17480. /**
  17481. * Creates a new rotation matrix for "angle" radians around the Y axis
  17482. * @param angle defines the angle (in radians) to use
  17483. * @return the new matrix
  17484. */
  17485. static RotationY(angle: number): Matrix;
  17486. /**
  17487. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17488. * @param angle defines the angle (in radians) to use
  17489. * @param result defines the target matrix
  17490. */
  17491. static RotationYToRef(angle: number, result: Matrix): void;
  17492. /**
  17493. * Creates a new rotation matrix for "angle" radians around the Z axis
  17494. * @param angle defines the angle (in radians) to use
  17495. * @return the new matrix
  17496. */
  17497. static RotationZ(angle: number): Matrix;
  17498. /**
  17499. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17500. * @param angle defines the angle (in radians) to use
  17501. * @param result defines the target matrix
  17502. */
  17503. static RotationZToRef(angle: number, result: Matrix): void;
  17504. /**
  17505. * Creates a new rotation matrix for "angle" radians around the given axis
  17506. * @param axis defines the axis to use
  17507. * @param angle defines the angle (in radians) to use
  17508. * @return the new matrix
  17509. */
  17510. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17511. /**
  17512. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17513. * @param axis defines the axis to use
  17514. * @param angle defines the angle (in radians) to use
  17515. * @param result defines the target matrix
  17516. */
  17517. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17518. /**
  17519. * Creates a rotation matrix
  17520. * @param yaw defines the yaw angle in radians (Y axis)
  17521. * @param pitch defines the pitch angle in radians (X axis)
  17522. * @param roll defines the roll angle in radians (X axis)
  17523. * @returns the new rotation matrix
  17524. */
  17525. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17526. /**
  17527. * Creates a rotation matrix and stores it in a given matrix
  17528. * @param yaw defines the yaw angle in radians (Y axis)
  17529. * @param pitch defines the pitch angle in radians (X axis)
  17530. * @param roll defines the roll angle in radians (X axis)
  17531. * @param result defines the target matrix
  17532. */
  17533. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17534. /**
  17535. * Creates a scaling matrix
  17536. * @param x defines the scale factor on X axis
  17537. * @param y defines the scale factor on Y axis
  17538. * @param z defines the scale factor on Z axis
  17539. * @returns the new matrix
  17540. */
  17541. static Scaling(x: number, y: number, z: number): Matrix;
  17542. /**
  17543. * Creates a scaling matrix and stores it in a given matrix
  17544. * @param x defines the scale factor on X axis
  17545. * @param y defines the scale factor on Y axis
  17546. * @param z defines the scale factor on Z axis
  17547. * @param result defines the target matrix
  17548. */
  17549. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17550. /**
  17551. * Creates a translation matrix
  17552. * @param x defines the translation on X axis
  17553. * @param y defines the translation on Y axis
  17554. * @param z defines the translationon Z axis
  17555. * @returns the new matrix
  17556. */
  17557. static Translation(x: number, y: number, z: number): Matrix;
  17558. /**
  17559. * Creates a translation matrix and stores it in a given matrix
  17560. * @param x defines the translation on X axis
  17561. * @param y defines the translation on Y axis
  17562. * @param z defines the translationon Z axis
  17563. * @param result defines the target matrix
  17564. */
  17565. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17566. /**
  17567. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17568. * @param startValue defines the start value
  17569. * @param endValue defines the end value
  17570. * @param gradient defines the gradient factor
  17571. * @returns the new matrix
  17572. */
  17573. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17574. /**
  17575. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17576. * @param startValue defines the start value
  17577. * @param endValue defines the end value
  17578. * @param gradient defines the gradient factor
  17579. * @param result defines the Matrix object where to store data
  17580. */
  17581. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17582. /**
  17583. * Builds a new matrix whose values are computed by:
  17584. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17585. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17586. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17587. * @param startValue defines the first matrix
  17588. * @param endValue defines the second matrix
  17589. * @param gradient defines the gradient between the two matrices
  17590. * @returns the new matrix
  17591. */
  17592. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17593. /**
  17594. * Update a matrix to values which are computed by:
  17595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17598. * @param startValue defines the first matrix
  17599. * @param endValue defines the second matrix
  17600. * @param gradient defines the gradient between the two matrices
  17601. * @param result defines the target matrix
  17602. */
  17603. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17604. /**
  17605. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  17606. * This function works in left handed mode
  17607. * @param eye defines the final position of the entity
  17608. * @param target defines where the entity should look at
  17609. * @param up defines the up vector for the entity
  17610. * @returns the new matrix
  17611. */
  17612. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17613. /**
  17614. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  17615. * This function works in left handed mode
  17616. * @param eye defines the final position of the entity
  17617. * @param target defines where the entity should look at
  17618. * @param up defines the up vector for the entity
  17619. * @param result defines the target matrix
  17620. */
  17621. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17622. /**
  17623. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  17624. * This function works in right handed mode
  17625. * @param eye defines the final position of the entity
  17626. * @param target defines where the entity should look at
  17627. * @param up defines the up vector for the entity
  17628. * @returns the new matrix
  17629. */
  17630. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17631. /**
  17632. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  17633. * This function works in right handed mode
  17634. * @param eye defines the final position of the entity
  17635. * @param target defines where the entity should look at
  17636. * @param up defines the up vector for the entity
  17637. * @param result defines the target matrix
  17638. */
  17639. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17640. /**
  17641. * Create a left-handed orthographic projection matrix
  17642. * @param width defines the viewport width
  17643. * @param height defines the viewport height
  17644. * @param znear defines the near clip plane
  17645. * @param zfar defines the far clip plane
  17646. * @returns a new matrix as a left-handed orthographic projection matrix
  17647. */
  17648. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17649. /**
  17650. * Store a left-handed orthographic projection to a given matrix
  17651. * @param width defines the viewport width
  17652. * @param height defines the viewport height
  17653. * @param znear defines the near clip plane
  17654. * @param zfar defines the far clip plane
  17655. * @param result defines the target matrix
  17656. */
  17657. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17658. /**
  17659. * Create a left-handed orthographic projection matrix
  17660. * @param left defines the viewport left coordinate
  17661. * @param right defines the viewport right coordinate
  17662. * @param bottom defines the viewport bottom coordinate
  17663. * @param top defines the viewport top coordinate
  17664. * @param znear defines the near clip plane
  17665. * @param zfar defines the far clip plane
  17666. * @returns a new matrix as a left-handed orthographic projection matrix
  17667. */
  17668. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17669. /**
  17670. * Stores a left-handed orthographic projection into a given matrix
  17671. * @param left defines the viewport left coordinate
  17672. * @param right defines the viewport right coordinate
  17673. * @param bottom defines the viewport bottom coordinate
  17674. * @param top defines the viewport top coordinate
  17675. * @param znear defines the near clip plane
  17676. * @param zfar defines the far clip plane
  17677. * @param result defines the target matrix
  17678. */
  17679. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17680. /**
  17681. * Creates a right-handed orthographic projection matrix
  17682. * @param left defines the viewport left coordinate
  17683. * @param right defines the viewport right coordinate
  17684. * @param bottom defines the viewport bottom coordinate
  17685. * @param top defines the viewport top coordinate
  17686. * @param znear defines the near clip plane
  17687. * @param zfar defines the far clip plane
  17688. * @returns a new matrix as a right-handed orthographic projection matrix
  17689. */
  17690. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17691. /**
  17692. * Stores a right-handed orthographic projection into a given matrix
  17693. * @param left defines the viewport left coordinate
  17694. * @param right defines the viewport right coordinate
  17695. * @param bottom defines the viewport bottom coordinate
  17696. * @param top defines the viewport top coordinate
  17697. * @param znear defines the near clip plane
  17698. * @param zfar defines the far clip plane
  17699. * @param result defines the target matrix
  17700. */
  17701. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17702. /**
  17703. * Creates a left-handed perspective projection matrix
  17704. * @param width defines the viewport width
  17705. * @param height defines the viewport height
  17706. * @param znear defines the near clip plane
  17707. * @param zfar defines the far clip plane
  17708. * @returns a new matrix as a left-handed perspective projection matrix
  17709. */
  17710. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17711. /**
  17712. * Creates a left-handed perspective projection matrix
  17713. * @param fov defines the horizontal field of view
  17714. * @param aspect defines the aspect ratio
  17715. * @param znear defines the near clip plane
  17716. * @param zfar defines the far clip plane
  17717. * @returns a new matrix as a left-handed perspective projection matrix
  17718. */
  17719. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17720. /**
  17721. * Stores a left-handed perspective projection into a given matrix
  17722. * @param fov defines the horizontal field of view
  17723. * @param aspect defines the aspect ratio
  17724. * @param znear defines the near clip plane
  17725. * @param zfar defines the far clip plane
  17726. * @param result defines the target matrix
  17727. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17728. */
  17729. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17730. /**
  17731. * Creates a right-handed perspective projection matrix
  17732. * @param fov defines the horizontal field of view
  17733. * @param aspect defines the aspect ratio
  17734. * @param znear defines the near clip plane
  17735. * @param zfar defines the far clip plane
  17736. * @returns a new matrix as a right-handed perspective projection matrix
  17737. */
  17738. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17739. /**
  17740. * Stores a right-handed perspective projection into a given matrix
  17741. * @param fov defines the horizontal field of view
  17742. * @param aspect defines the aspect ratio
  17743. * @param znear defines the near clip plane
  17744. * @param zfar defines the far clip plane
  17745. * @param result defines the target matrix
  17746. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17747. */
  17748. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17749. /**
  17750. * Stores a perspective projection for WebVR info a given matrix
  17751. * @param fov defines the field of view
  17752. * @param znear defines the near clip plane
  17753. * @param zfar defines the far clip plane
  17754. * @param result defines the target matrix
  17755. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17756. */
  17757. static PerspectiveFovWebVRToRef(fov: {
  17758. upDegrees: number;
  17759. downDegrees: number;
  17760. leftDegrees: number;
  17761. rightDegrees: number;
  17762. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17763. /**
  17764. * Computes a complete transformation matrix
  17765. * @param viewport defines the viewport to use
  17766. * @param world defines the world matrix
  17767. * @param view defines the view matrix
  17768. * @param projection defines the projection matrix
  17769. * @param zmin defines the near clip plane
  17770. * @param zmax defines the far clip plane
  17771. * @returns the transformation matrix
  17772. */
  17773. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17774. /**
  17775. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17776. * @param matrix defines the matrix to use
  17777. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  17778. */
  17779. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  17780. /**
  17781. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  17782. * @param matrix defines the matrix to use
  17783. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  17784. */
  17785. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  17786. /**
  17787. * Compute the transpose of a given matrix
  17788. * @param matrix defines the matrix to transpose
  17789. * @returns the new matrix
  17790. */
  17791. static Transpose(matrix: Matrix): Matrix;
  17792. /**
  17793. * Compute the transpose of a matrix and store it in a target matrix
  17794. * @param matrix defines the matrix to transpose
  17795. * @param result defines the target matrix
  17796. */
  17797. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  17798. /**
  17799. * Computes a reflection matrix from a plane
  17800. * @param plane defines the reflection plane
  17801. * @returns a new matrix
  17802. */
  17803. static Reflection(plane: Plane): Matrix;
  17804. /**
  17805. * Computes a reflection matrix from a plane
  17806. * @param plane defines the reflection plane
  17807. * @param result defines the target matrix
  17808. */
  17809. static ReflectionToRef(plane: Plane, result: Matrix): void;
  17810. /**
  17811. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  17812. * @param xaxis defines the value of the 1st axis
  17813. * @param yaxis defines the value of the 2nd axis
  17814. * @param zaxis defines the value of the 3rd axis
  17815. * @param result defines the target matrix
  17816. */
  17817. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  17818. /**
  17819. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  17820. * @param quat defines the quaternion to use
  17821. * @param result defines the target matrix
  17822. */
  17823. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  17824. }
  17825. class Plane {
  17826. normal: Vector3;
  17827. d: number;
  17828. /**
  17829. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  17830. */
  17831. constructor(a: number, b: number, c: number, d: number);
  17832. /**
  17833. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  17834. */
  17835. asArray(): number[];
  17836. /**
  17837. * Returns a new plane copied from the current Plane.
  17838. */
  17839. clone(): Plane;
  17840. /**
  17841. * Returns the string "Plane".
  17842. */
  17843. getClassName(): string;
  17844. /**
  17845. * Returns the Plane hash code.
  17846. */
  17847. getHashCode(): number;
  17848. /**
  17849. * Normalize the current Plane in place.
  17850. * Returns the updated Plane.
  17851. */
  17852. normalize(): Plane;
  17853. /**
  17854. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  17855. */
  17856. transform(transformation: Matrix): Plane;
  17857. /**
  17858. * Returns the dot product (float) of the point coordinates and the plane normal.
  17859. */
  17860. dotCoordinate(point: Vector3): number;
  17861. /**
  17862. * Updates the current Plane from the plane defined by the three given points.
  17863. * Returns the updated Plane.
  17864. */
  17865. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17866. /**
  17867. * Boolean : True is the vector "direction" is the same side than the plane normal.
  17868. */
  17869. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  17870. /**
  17871. * Returns the signed distance (float) from the given point to the Plane.
  17872. */
  17873. signedDistanceTo(point: Vector3): number;
  17874. /**
  17875. * Returns a new Plane from the given array.
  17876. */
  17877. static FromArray(array: ArrayLike<number>): Plane;
  17878. /**
  17879. * Returns a new Plane defined by the three given points.
  17880. */
  17881. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17882. /**
  17883. * Returns a new Plane the normal vector to this plane at the given origin point.
  17884. * Note : the vector "normal" is updated because normalized.
  17885. */
  17886. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  17887. /**
  17888. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  17889. */
  17890. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  17891. }
  17892. class Viewport {
  17893. x: number;
  17894. y: number;
  17895. width: number;
  17896. height: number;
  17897. /**
  17898. * Creates a Viewport object located at (x, y) and sized (width, height).
  17899. */
  17900. constructor(x: number, y: number, width: number, height: number);
  17901. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  17902. /**
  17903. * Returns a new Viewport copied from the current one.
  17904. */
  17905. clone(): Viewport;
  17906. }
  17907. class Frustum {
  17908. /**
  17909. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  17910. */
  17911. static GetPlanes(transform: Matrix): Plane[];
  17912. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17913. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17914. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17915. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17916. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17917. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17918. /**
  17919. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  17920. */
  17921. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  17922. }
  17923. /** Defines supported spaces */
  17924. enum Space {
  17925. /** Local (object) space */
  17926. LOCAL = 0,
  17927. /** World space */
  17928. WORLD = 1,
  17929. /** Bone space */
  17930. BONE = 2,
  17931. }
  17932. /** Defines the 3 main axes */
  17933. class Axis {
  17934. /** X axis */
  17935. static X: Vector3;
  17936. /** Y axis */
  17937. static Y: Vector3;
  17938. /** Z axis */
  17939. static Z: Vector3;
  17940. }
  17941. class BezierCurve {
  17942. /**
  17943. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  17944. */
  17945. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  17946. }
  17947. /**
  17948. * Defines potential orientation for back face culling
  17949. */
  17950. enum Orientation {
  17951. /**
  17952. * Clockwise
  17953. */
  17954. CW = 0,
  17955. /** Counter clockwise */
  17956. CCW = 1,
  17957. }
  17958. /**
  17959. * Defines angle representation
  17960. */
  17961. class Angle {
  17962. private _radians;
  17963. /**
  17964. * Creates an Angle object of "radians" radians (float).
  17965. */
  17966. constructor(radians: number);
  17967. /**
  17968. * Get value in degrees
  17969. * @returns the Angle value in degrees (float)
  17970. */
  17971. degrees(): number;
  17972. /**
  17973. * Get value in radians
  17974. * @returns the Angle value in radians (float)
  17975. */
  17976. radians(): number;
  17977. /**
  17978. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  17979. * @param a defines first vector
  17980. * @param b defines second vector
  17981. * @returns a new Angle
  17982. */
  17983. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  17984. /**
  17985. * Gets a new Angle object from the given float in radians
  17986. * @param radians defines the angle value in radians
  17987. * @returns a new Angle
  17988. */
  17989. static FromRadians(radians: number): Angle;
  17990. /**
  17991. * Gets a new Angle object from the given float in degrees
  17992. * @param degrees defines the angle value in degrees
  17993. * @returns a new Angle
  17994. */
  17995. static FromDegrees(degrees: number): Angle;
  17996. }
  17997. class Arc2 {
  17998. startPoint: Vector2;
  17999. midPoint: Vector2;
  18000. endPoint: Vector2;
  18001. centerPoint: Vector2;
  18002. radius: number;
  18003. angle: Angle;
  18004. startAngle: Angle;
  18005. orientation: Orientation;
  18006. /**
  18007. * Creates an Arc object from the three given points : start, middle and end.
  18008. */
  18009. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18010. }
  18011. class Path2 {
  18012. private _points;
  18013. private _length;
  18014. closed: boolean;
  18015. /**
  18016. * Creates a Path2 object from the starting 2D coordinates x and y.
  18017. */
  18018. constructor(x: number, y: number);
  18019. /**
  18020. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18021. * Returns the updated Path2.
  18022. */
  18023. addLineTo(x: number, y: number): Path2;
  18024. /**
  18025. * 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.
  18026. * Returns the updated Path2.
  18027. */
  18028. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18029. /**
  18030. * Closes the Path2.
  18031. * Returns the Path2.
  18032. */
  18033. close(): Path2;
  18034. /**
  18035. * Returns the Path2 total length (float).
  18036. */
  18037. length(): number;
  18038. /**
  18039. * Returns the Path2 internal array of points.
  18040. */
  18041. getPoints(): Vector2[];
  18042. /**
  18043. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18044. */
  18045. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18046. /**
  18047. * Returns a new Path2 starting at the coordinates (x, y).
  18048. */
  18049. static StartingAt(x: number, y: number): Path2;
  18050. }
  18051. class Path3D {
  18052. path: Vector3[];
  18053. private _curve;
  18054. private _distances;
  18055. private _tangents;
  18056. private _normals;
  18057. private _binormals;
  18058. private _raw;
  18059. /**
  18060. * new Path3D(path, normal, raw)
  18061. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18062. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18063. * path : an array of Vector3, the curve axis of the Path3D
  18064. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18065. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18066. */
  18067. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18068. /**
  18069. * Returns the Path3D array of successive Vector3 designing its curve.
  18070. */
  18071. getCurve(): Vector3[];
  18072. /**
  18073. * Returns an array populated with tangent vectors on each Path3D curve point.
  18074. */
  18075. getTangents(): Vector3[];
  18076. /**
  18077. * Returns an array populated with normal vectors on each Path3D curve point.
  18078. */
  18079. getNormals(): Vector3[];
  18080. /**
  18081. * Returns an array populated with binormal vectors on each Path3D curve point.
  18082. */
  18083. getBinormals(): Vector3[];
  18084. /**
  18085. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18086. */
  18087. getDistances(): number[];
  18088. /**
  18089. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18090. * Returns the same object updated.
  18091. */
  18092. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18093. private _compute(firstNormal);
  18094. private _getFirstNonNullVector(index);
  18095. private _getLastNonNullVector(index);
  18096. private _normalVector(v0, vt, va);
  18097. }
  18098. class Curve3 {
  18099. private _points;
  18100. private _length;
  18101. /**
  18102. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18103. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18104. * @param v1 (Vector3) the control point
  18105. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18106. * @param nbPoints (integer) the wanted number of points in the curve
  18107. */
  18108. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18109. /**
  18110. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18111. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18112. * @param v1 (Vector3) the first control point
  18113. * @param v2 (Vector3) the second control point
  18114. * @param v3 (Vector3) the end point of the Cubic Bezier
  18115. * @param nbPoints (integer) the wanted number of points in the curve
  18116. */
  18117. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18118. /**
  18119. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18120. * @param p1 (Vector3) the origin point of the Hermite Spline
  18121. * @param t1 (Vector3) the tangent vector at the origin point
  18122. * @param p2 (Vector3) the end point of the Hermite Spline
  18123. * @param t2 (Vector3) the tangent vector at the end point
  18124. * @param nbPoints (integer) the wanted number of points in the curve
  18125. */
  18126. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18127. /**
  18128. * Returns a Curve3 object along a CatmullRom Spline curve :
  18129. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18130. * @param nbPoints (integer) the wanted number of points between each curve control points
  18131. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18132. */
  18133. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18134. /**
  18135. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18136. * A Curve3 is designed from a series of successive Vector3.
  18137. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18138. */
  18139. constructor(points: Vector3[]);
  18140. /**
  18141. * Returns the Curve3 stored array of successive Vector3
  18142. */
  18143. getPoints(): Vector3[];
  18144. /**
  18145. * Returns the computed length (float) of the curve.
  18146. */
  18147. length(): number;
  18148. /**
  18149. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18150. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18151. * curveA and curveB keep unchanged.
  18152. */
  18153. continue(curve: Curve3): Curve3;
  18154. private _computeLength(path);
  18155. }
  18156. class PositionNormalVertex {
  18157. position: Vector3;
  18158. normal: Vector3;
  18159. constructor(position?: Vector3, normal?: Vector3);
  18160. clone(): PositionNormalVertex;
  18161. }
  18162. class PositionNormalTextureVertex {
  18163. position: Vector3;
  18164. normal: Vector3;
  18165. uv: Vector2;
  18166. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18167. clone(): PositionNormalTextureVertex;
  18168. }
  18169. class Tmp {
  18170. static Color3: Color3[];
  18171. static Vector2: Vector2[];
  18172. static Vector3: Vector3[];
  18173. static Vector4: Vector4[];
  18174. static Quaternion: Quaternion[];
  18175. static Matrix: Matrix[];
  18176. }
  18177. }
  18178. declare module BABYLON {
  18179. class SphericalPolynomial {
  18180. x: Vector3;
  18181. y: Vector3;
  18182. z: Vector3;
  18183. xx: Vector3;
  18184. yy: Vector3;
  18185. zz: Vector3;
  18186. xy: Vector3;
  18187. yz: Vector3;
  18188. zx: Vector3;
  18189. addAmbient(color: Color3): void;
  18190. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18191. scale(scale: number): void;
  18192. }
  18193. class SphericalHarmonics {
  18194. L00: Vector3;
  18195. L1_1: Vector3;
  18196. L10: Vector3;
  18197. L11: Vector3;
  18198. L2_2: Vector3;
  18199. L2_1: Vector3;
  18200. L20: Vector3;
  18201. L21: Vector3;
  18202. L22: Vector3;
  18203. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18204. scale(scale: number): void;
  18205. convertIncidentRadianceToIrradiance(): void;
  18206. convertIrradianceToLambertianRadiance(): void;
  18207. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18208. }
  18209. }
  18210. declare module BABYLON {
  18211. /**
  18212. * Defines a target to use with MorphTargetManager
  18213. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18214. */
  18215. class MorphTarget implements IAnimatable {
  18216. /** defines the name of the target */
  18217. name: string;
  18218. /**
  18219. * Gets or sets the list of animations
  18220. */
  18221. animations: Animation[];
  18222. private _scene;
  18223. private _positions;
  18224. private _normals;
  18225. private _tangents;
  18226. private _influence;
  18227. /**
  18228. * Observable raised when the influence changes
  18229. */
  18230. onInfluenceChanged: Observable<boolean>;
  18231. /**
  18232. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18233. */
  18234. influence: number;
  18235. private _animationPropertiesOverride;
  18236. /**
  18237. * Gets or sets the animation properties override
  18238. */
  18239. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18240. /**
  18241. * Creates a new MorphTarget
  18242. * @param name defines the name of the target
  18243. * @param influence defines the influence to use
  18244. */
  18245. constructor(
  18246. /** defines the name of the target */
  18247. name: string, influence?: number, scene?: Nullable<Scene>);
  18248. /**
  18249. * Gets a boolean defining if the target contains position data
  18250. */
  18251. readonly hasPositions: boolean;
  18252. /**
  18253. * Gets a boolean defining if the target contains normal data
  18254. */
  18255. readonly hasNormals: boolean;
  18256. /**
  18257. * Gets a boolean defining if the target contains tangent data
  18258. */
  18259. readonly hasTangents: boolean;
  18260. /**
  18261. * Affects position data to this target
  18262. * @param data defines the position data to use
  18263. */
  18264. setPositions(data: Nullable<FloatArray>): void;
  18265. /**
  18266. * Gets the position data stored in this target
  18267. * @returns a FloatArray containing the position data (or null if not present)
  18268. */
  18269. getPositions(): Nullable<FloatArray>;
  18270. /**
  18271. * Affects normal data to this target
  18272. * @param data defines the normal data to use
  18273. */
  18274. setNormals(data: Nullable<FloatArray>): void;
  18275. /**
  18276. * Gets the normal data stored in this target
  18277. * @returns a FloatArray containing the normal data (or null if not present)
  18278. */
  18279. getNormals(): Nullable<FloatArray>;
  18280. /**
  18281. * Affects tangent data to this target
  18282. * @param data defines the tangent data to use
  18283. */
  18284. setTangents(data: Nullable<FloatArray>): void;
  18285. /**
  18286. * Gets the tangent data stored in this target
  18287. * @returns a FloatArray containing the tangent data (or null if not present)
  18288. */
  18289. getTangents(): Nullable<FloatArray>;
  18290. /**
  18291. * Serializes the current target into a Serialization object
  18292. * @returns the serialized object
  18293. */
  18294. serialize(): any;
  18295. /**
  18296. * Creates a new target from serialized data
  18297. * @param serializationObject defines the serialized data to use
  18298. * @returns a new MorphTarget
  18299. */
  18300. static Parse(serializationObject: any): MorphTarget;
  18301. /**
  18302. * Creates a MorphTarget from mesh data
  18303. * @param mesh defines the source mesh
  18304. * @param name defines the name to use for the new target
  18305. * @param influence defines the influence to attach to the target
  18306. * @returns a new MorphTarget
  18307. */
  18308. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18309. }
  18310. }
  18311. declare module BABYLON {
  18312. /**
  18313. * This class is used to deform meshes using morphing between different targets
  18314. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18315. */
  18316. class MorphTargetManager {
  18317. private _targets;
  18318. private _targetObservable;
  18319. private _activeTargets;
  18320. private _scene;
  18321. private _influences;
  18322. private _supportsNormals;
  18323. private _supportsTangents;
  18324. private _vertexCount;
  18325. private _uniqueId;
  18326. private _tempInfluences;
  18327. /**
  18328. * Creates a new MorphTargetManager
  18329. * @param scene defines the current scene
  18330. */
  18331. constructor(scene?: Nullable<Scene>);
  18332. /**
  18333. * Gets the unique ID of this manager
  18334. */
  18335. readonly uniqueId: number;
  18336. /**
  18337. * Gets the number of vertices handled by this manager
  18338. */
  18339. readonly vertexCount: number;
  18340. /**
  18341. * Gets a boolean indicating if this manager supports morphing of normals
  18342. */
  18343. readonly supportsNormals: boolean;
  18344. /**
  18345. * Gets a boolean indicating if this manager supports morphing of tangents
  18346. */
  18347. readonly supportsTangents: boolean;
  18348. /**
  18349. * Gets the number of targets stored in this manager
  18350. */
  18351. readonly numTargets: number;
  18352. /**
  18353. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18354. */
  18355. readonly numInfluencers: number;
  18356. /**
  18357. * Gets the list of influences (one per target)
  18358. */
  18359. readonly influences: Float32Array;
  18360. /**
  18361. * Gets the active target at specified index. An active target is a target with an influence > 0
  18362. * @param index defines the index to check
  18363. * @returns the requested target
  18364. */
  18365. getActiveTarget(index: number): MorphTarget;
  18366. /**
  18367. * Gets the target at specified index
  18368. * @param index defines the index to check
  18369. * @returns the requested target
  18370. */
  18371. getTarget(index: number): MorphTarget;
  18372. /**
  18373. * Add a new target to this manager
  18374. * @param target defines the target to add
  18375. */
  18376. addTarget(target: MorphTarget): void;
  18377. /**
  18378. * Removes a target from the manager
  18379. * @param target defines the target to remove
  18380. */
  18381. removeTarget(target: MorphTarget): void;
  18382. /**
  18383. * Serializes the current manager into a Serialization object
  18384. * @returns the serialized object
  18385. */
  18386. serialize(): any;
  18387. private _syncActiveTargets(needUpdate);
  18388. /**
  18389. * Syncrhonize the targets with all the meshes using this morph target manager
  18390. */
  18391. synchronize(): void;
  18392. /**
  18393. * Creates a new MorphTargetManager from serialized data
  18394. * @param serializationObject defines the serialized data
  18395. * @param scene defines the hosting scene
  18396. * @returns the new MorphTargetManager
  18397. */
  18398. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18399. }
  18400. }
  18401. declare module BABYLON {
  18402. /**
  18403. * This represents a GPU particle system in Babylon
  18404. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  18405. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  18406. */
  18407. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  18408. /**
  18409. * The id of the Particle system.
  18410. */
  18411. id: string;
  18412. /**
  18413. * The friendly name of the Particle system.
  18414. */
  18415. name: string;
  18416. /**
  18417. * The emitter represents the Mesh or position we are attaching the particle system to.
  18418. */
  18419. emitter: Nullable<AbstractMesh | Vector3>;
  18420. /**
  18421. * The rendering group used by the Particle system to chose when to render.
  18422. */
  18423. renderingGroupId: number;
  18424. /**
  18425. * The layer mask we are rendering the particles through.
  18426. */
  18427. layerMask: number;
  18428. private _capacity;
  18429. private _activeCount;
  18430. private _currentActiveCount;
  18431. private _renderEffect;
  18432. private _updateEffect;
  18433. private _buffer0;
  18434. private _buffer1;
  18435. private _spriteBuffer;
  18436. private _updateVAO;
  18437. private _renderVAO;
  18438. private _targetIndex;
  18439. private _sourceBuffer;
  18440. private _targetBuffer;
  18441. private _scene;
  18442. private _engine;
  18443. private _currentRenderId;
  18444. private _started;
  18445. private _stopped;
  18446. private _timeDelta;
  18447. private _randomTexture;
  18448. private readonly _attributesStrideSize;
  18449. private _updateEffectOptions;
  18450. private _randomTextureSize;
  18451. private _actualFrame;
  18452. /**
  18453. * List of animations used by the particle system.
  18454. */
  18455. animations: Animation[];
  18456. /**
  18457. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  18458. */
  18459. static readonly IsSupported: boolean;
  18460. /**
  18461. * An event triggered when the system is disposed.
  18462. */
  18463. onDisposeObservable: Observable<GPUParticleSystem>;
  18464. /**
  18465. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18466. */
  18467. updateSpeed: number;
  18468. /**
  18469. * The amount of time the particle system is running (depends of the overall update speed).
  18470. */
  18471. targetStopDuration: number;
  18472. /**
  18473. * The texture used to render each particle. (this can be a spritesheet)
  18474. */
  18475. particleTexture: Nullable<Texture>;
  18476. /**
  18477. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18478. */
  18479. blendMode: number;
  18480. /**
  18481. * Minimum life time of emitting particles.
  18482. */
  18483. minLifeTime: number;
  18484. /**
  18485. * Maximum life time of emitting particles.
  18486. */
  18487. maxLifeTime: number;
  18488. /**
  18489. * Minimum Size of emitting particles.
  18490. */
  18491. minSize: number;
  18492. /**
  18493. * Maximum Size of emitting particles.
  18494. */
  18495. maxSize: number;
  18496. /**
  18497. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18498. */
  18499. color1: Color4;
  18500. /**
  18501. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18502. */
  18503. color2: Color4;
  18504. /**
  18505. * Color the particle will have at the end of its lifetime.
  18506. */
  18507. colorDead: Color4;
  18508. /**
  18509. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18510. */
  18511. emitRate: number;
  18512. /**
  18513. * You can use gravity if you want to give an orientation to your particles.
  18514. */
  18515. gravity: Vector3;
  18516. /**
  18517. * Minimum power of emitting particles.
  18518. */
  18519. minEmitPower: number;
  18520. /**
  18521. * Maximum power of emitting particles.
  18522. */
  18523. maxEmitPower: number;
  18524. /**
  18525. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18526. */
  18527. minAngularSpeed: number;
  18528. /**
  18529. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18530. */
  18531. maxAngularSpeed: number;
  18532. /**
  18533. * The particle emitter type defines the emitter used by the particle system.
  18534. * It can be for example box, sphere, or cone...
  18535. */
  18536. particleEmitterType: Nullable<IParticleEmitterType>;
  18537. /**
  18538. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18540. */
  18541. direction1: Vector3;
  18542. /**
  18543. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18544. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18545. */
  18546. direction2: Vector3;
  18547. /**
  18548. * 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.
  18549. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18550. */
  18551. minEmitBox: Vector3;
  18552. /**
  18553. * 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.
  18554. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18555. */
  18556. maxEmitBox: Vector3;
  18557. /**
  18558. * Gets the maximum number of particles active at the same time.
  18559. * @returns The max number of active particles.
  18560. */
  18561. getCapacity(): number;
  18562. /**
  18563. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18564. * to override the particles.
  18565. */
  18566. forceDepthWrite: boolean;
  18567. /**
  18568. * Gets or set the number of active particles
  18569. */
  18570. activeParticleCount: number;
  18571. /**
  18572. * Is this system ready to be used/rendered
  18573. * @return true if the system is ready
  18574. */
  18575. isReady(): boolean;
  18576. /**
  18577. * Gets Wether the system has been started.
  18578. * @returns True if it has been started, otherwise false.
  18579. */
  18580. isStarted(): boolean;
  18581. /**
  18582. * Starts the particle system and begins to emit.
  18583. */
  18584. start(): void;
  18585. /**
  18586. * Stops the particle system.
  18587. */
  18588. stop(): void;
  18589. /**
  18590. * Remove all active particles
  18591. */
  18592. reset(): void;
  18593. /**
  18594. * Returns the string "GPUParticleSystem"
  18595. * @returns a string containing the class name
  18596. */
  18597. getClassName(): string;
  18598. /**
  18599. * Instantiates a GPU particle system.
  18600. * 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.
  18601. * @param name The name of the particle system
  18602. * @param capacity The max number of particles alive at the same time
  18603. * @param scene The scene the particle system belongs to
  18604. */
  18605. constructor(name: string, options: Partial<{
  18606. capacity: number;
  18607. randomTextureSize: number;
  18608. }>, scene: Scene);
  18609. private _createUpdateVAO(source);
  18610. private _createRenderVAO(source, spriteSource);
  18611. private _initialize(force?);
  18612. /** @hidden */
  18613. _recreateUpdateEffect(): void;
  18614. /** @hidden */
  18615. _recreateRenderEffect(): void;
  18616. /**
  18617. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18618. */
  18619. animate(): void;
  18620. /**
  18621. * Renders the particle system in its current state.
  18622. * @returns the current number of particles
  18623. */
  18624. render(): number;
  18625. /**
  18626. * Rebuilds the particle system
  18627. */
  18628. rebuild(): void;
  18629. private _releaseBuffers();
  18630. private _releaseVAOs();
  18631. /**
  18632. * Disposes the particle system and free the associated resources
  18633. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18634. */
  18635. dispose(disposeTexture?: boolean): void;
  18636. /**
  18637. * Clones the particle system.
  18638. * @param name The name of the cloned object
  18639. * @param newEmitter The new emitter to use
  18640. * @returns the cloned particle system
  18641. */
  18642. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  18643. /**
  18644. * Serializes the particle system to a JSON object.
  18645. * @returns the JSON object
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Parses a JSON object to create a GPU particle system.
  18650. * @param parsedParticleSystem The JSON object to parse
  18651. * @param scene The scene to create the particle system in
  18652. * @param rootUrl The root url to use to load external dependencies like texture
  18653. * @returns the parsed GPU particle system
  18654. */
  18655. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  18656. }
  18657. }
  18658. declare module BABYLON {
  18659. /**
  18660. * Interface representing a particle system in Babylon.
  18661. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18662. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18663. */
  18664. interface IParticleSystem {
  18665. /**
  18666. * The id of the Particle system.
  18667. */
  18668. id: string;
  18669. /**
  18670. * The name of the Particle system.
  18671. */
  18672. name: string;
  18673. /**
  18674. * The emitter represents the Mesh or position we are attaching the particle system to.
  18675. */
  18676. emitter: Nullable<AbstractMesh | Vector3>;
  18677. /**
  18678. * The rendering group used by the Particle system to chose when to render.
  18679. */
  18680. renderingGroupId: number;
  18681. /**
  18682. * The layer mask we are rendering the particles through.
  18683. */
  18684. layerMask: number;
  18685. /**
  18686. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18687. */
  18688. updateSpeed: number;
  18689. /**
  18690. * The amount of time the particle system is running (depends of the overall update speed).
  18691. */
  18692. targetStopDuration: number;
  18693. /**
  18694. * The texture used to render each particle. (this can be a spritesheet)
  18695. */
  18696. particleTexture: Nullable<Texture>;
  18697. /**
  18698. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18699. */
  18700. blendMode: number;
  18701. /**
  18702. * Minimum life time of emitting particles.
  18703. */
  18704. minLifeTime: number;
  18705. /**
  18706. * Maximum life time of emitting particles.
  18707. */
  18708. maxLifeTime: number;
  18709. /**
  18710. * Minimum Size of emitting particles.
  18711. */
  18712. minSize: number;
  18713. /**
  18714. * Maximum Size of emitting particles.
  18715. */
  18716. maxSize: number;
  18717. /**
  18718. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18719. */
  18720. color1: Color4;
  18721. /**
  18722. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18723. */
  18724. color2: Color4;
  18725. /**
  18726. * Color the particle will have at the end of its lifetime.
  18727. */
  18728. colorDead: Color4;
  18729. /**
  18730. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18731. */
  18732. emitRate: number;
  18733. /**
  18734. * You can use gravity if you want to give an orientation to your particles.
  18735. */
  18736. gravity: Vector3;
  18737. /**
  18738. * Minimum power of emitting particles.
  18739. */
  18740. minEmitPower: number;
  18741. /**
  18742. * Maximum power of emitting particles.
  18743. */
  18744. maxEmitPower: number;
  18745. /**
  18746. * The particle emitter type defines the emitter used by the particle system.
  18747. * It can be for example box, sphere, or cone...
  18748. */
  18749. particleEmitterType: Nullable<IParticleEmitterType>;
  18750. /**
  18751. * Gets the maximum number of particles active at the same time.
  18752. * @returns The max number of active particles.
  18753. */
  18754. getCapacity(): number;
  18755. /**
  18756. * Gets Wether the system has been started.
  18757. * @returns True if it has been started, otherwise false.
  18758. */
  18759. isStarted(): boolean;
  18760. /**
  18761. * Gets if the particle system has been started.
  18762. * @return true if the system has been started, otherwise false.
  18763. */
  18764. isStarted(): boolean;
  18765. /**
  18766. * Animates the particle system for this frame.
  18767. */
  18768. animate(): void;
  18769. /**
  18770. * Renders the particle system in its current state.
  18771. * @returns the current number of particles
  18772. */
  18773. render(): number;
  18774. /**
  18775. * Dispose the particle system and frees its associated resources.
  18776. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18777. */
  18778. dispose(disposeTexture?: boolean): void;
  18779. /**
  18780. * Clones the particle system.
  18781. * @param name The name of the cloned object
  18782. * @param newEmitter The new emitter to use
  18783. * @returns the cloned particle system
  18784. */
  18785. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18786. /**
  18787. * Serializes the particle system to a JSON object.
  18788. * @returns the JSON object
  18789. */
  18790. serialize(): any;
  18791. /**
  18792. * Rebuild the particle system
  18793. */
  18794. rebuild(): void;
  18795. /**
  18796. * Starts the particle system and begins to emit.
  18797. */
  18798. start(): void;
  18799. /**
  18800. * Stops the particle system.
  18801. */
  18802. stop(): void;
  18803. /**
  18804. * Remove all active particles
  18805. */
  18806. reset(): void;
  18807. /**
  18808. * Is this system ready to be used/rendered
  18809. * @return true if the system is ready
  18810. */
  18811. isReady(): boolean;
  18812. }
  18813. }
  18814. declare module BABYLON {
  18815. /**
  18816. * A particle represents one of the element emitted by a particle system.
  18817. * This is mainly define by its coordinates, direction, velocity and age.
  18818. */
  18819. class Particle {
  18820. /**
  18821. * particleSystem the particle system the particle belongs to.
  18822. */
  18823. particleSystem: ParticleSystem;
  18824. /**
  18825. * The world position of the particle in the scene.
  18826. */
  18827. position: Vector3;
  18828. /**
  18829. * The world direction of the particle in the scene.
  18830. */
  18831. direction: Vector3;
  18832. /**
  18833. * The color of the particle.
  18834. */
  18835. color: Color4;
  18836. /**
  18837. * The color change of the particle per step.
  18838. */
  18839. colorStep: Color4;
  18840. /**
  18841. * Defines how long will the life of the particle be.
  18842. */
  18843. lifeTime: number;
  18844. /**
  18845. * The current age of the particle.
  18846. */
  18847. age: number;
  18848. /**
  18849. * The current size of the particle.
  18850. */
  18851. size: number;
  18852. /**
  18853. * The current angle of the particle.
  18854. */
  18855. angle: number;
  18856. /**
  18857. * Defines how fast is the angle changing.
  18858. */
  18859. angularSpeed: number;
  18860. /**
  18861. * Defines the cell index used by the particle to be rendered from a sprite.
  18862. */
  18863. cellIndex: number;
  18864. private _currentFrameCounter;
  18865. /**
  18866. * Creates a new instance Particle
  18867. * @param particleSystem the particle system the particle belongs to
  18868. */
  18869. constructor(
  18870. /**
  18871. * particleSystem the particle system the particle belongs to.
  18872. */
  18873. particleSystem: ParticleSystem);
  18874. private updateCellInfoFromSystem();
  18875. /**
  18876. * Defines how the sprite cell index is updated for the particle. This is
  18877. * defined as a callback.
  18878. */
  18879. updateCellIndex: (scaledUpdateSpeed: number) => void;
  18880. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  18881. private _updateCellIndexWithCustomSpeed();
  18882. /**
  18883. * Copy the properties of particle to another one.
  18884. * @param other the particle to copy the information to.
  18885. */
  18886. copyTo(other: Particle): void;
  18887. }
  18888. }
  18889. declare module BABYLON {
  18890. /**
  18891. * This represents a particle system in Babylon.
  18892. * 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.
  18893. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18894. * @example https://doc.babylonjs.com/babylon101/particles
  18895. */
  18896. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18897. /**
  18898. * Source color is added to the destination color without alpha affecting the result.
  18899. */
  18900. static BLENDMODE_ONEONE: number;
  18901. /**
  18902. * Blend current color and particle color using particle’s alpha.
  18903. */
  18904. static BLENDMODE_STANDARD: number;
  18905. /**
  18906. * List of animations used by the particle system.
  18907. */
  18908. animations: Animation[];
  18909. /**
  18910. * The id of the Particle system.
  18911. */
  18912. id: string;
  18913. /**
  18914. * The friendly name of the Particle system.
  18915. */
  18916. name: string;
  18917. /**
  18918. * The rendering group used by the Particle system to chose when to render.
  18919. */
  18920. renderingGroupId: number;
  18921. /**
  18922. * The emitter represents the Mesh or position we are attaching the particle system to.
  18923. */
  18924. emitter: Nullable<AbstractMesh | Vector3>;
  18925. /**
  18926. * The maximum number of particles to emit per frame
  18927. */
  18928. emitRate: number;
  18929. /**
  18930. * If you want to launch only a few particles at once, that can be done, as well.
  18931. */
  18932. manualEmitCount: number;
  18933. /**
  18934. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18935. */
  18936. updateSpeed: number;
  18937. /**
  18938. * The amount of time the particle system is running (depends of the overall update speed).
  18939. */
  18940. targetStopDuration: number;
  18941. /**
  18942. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18943. */
  18944. disposeOnStop: boolean;
  18945. /**
  18946. * Minimum power of emitting particles.
  18947. */
  18948. minEmitPower: number;
  18949. /**
  18950. * Maximum power of emitting particles.
  18951. */
  18952. maxEmitPower: number;
  18953. /**
  18954. * Minimum life time of emitting particles.
  18955. */
  18956. minLifeTime: number;
  18957. /**
  18958. * Maximum life time of emitting particles.
  18959. */
  18960. maxLifeTime: number;
  18961. /**
  18962. * Minimum Size of emitting particles.
  18963. */
  18964. minSize: number;
  18965. /**
  18966. * Maximum Size of emitting particles.
  18967. */
  18968. maxSize: number;
  18969. /**
  18970. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18971. */
  18972. minAngularSpeed: number;
  18973. /**
  18974. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18975. */
  18976. maxAngularSpeed: number;
  18977. /**
  18978. * The texture used to render each particle. (this can be a spritesheet)
  18979. */
  18980. particleTexture: Nullable<Texture>;
  18981. /**
  18982. * The layer mask we are rendering the particles through.
  18983. */
  18984. layerMask: number;
  18985. /**
  18986. * This can help using your own shader to render the particle system.
  18987. * The according effect will be created
  18988. */
  18989. customShader: any;
  18990. /**
  18991. * By default particle system starts as soon as they are created. This prevents the
  18992. * automatic start to happen and let you decide when to start emitting particles.
  18993. */
  18994. preventAutoStart: boolean;
  18995. /**
  18996. * This function can be defined to provide custom update for active particles.
  18997. * This function will be called instead of regular update (age, position, color, etc.).
  18998. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18999. */
  19000. updateFunction: (particles: Particle[]) => void;
  19001. /**
  19002. * Callback triggered when the particle animation is ending.
  19003. */
  19004. onAnimationEnd: Nullable<() => void>;
  19005. /**
  19006. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19007. */
  19008. blendMode: number;
  19009. /**
  19010. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19011. * to override the particles.
  19012. */
  19013. forceDepthWrite: boolean;
  19014. /**
  19015. * You can use gravity if you want to give an orientation to your particles.
  19016. */
  19017. gravity: Vector3;
  19018. /**
  19019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19020. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19021. */
  19022. direction1: Vector3;
  19023. /**
  19024. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19025. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19026. */
  19027. direction2: Vector3;
  19028. /**
  19029. * 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.
  19030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19031. */
  19032. minEmitBox: Vector3;
  19033. /**
  19034. * 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.
  19035. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19036. */
  19037. maxEmitBox: Vector3;
  19038. /**
  19039. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19040. */
  19041. color1: Color4;
  19042. /**
  19043. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19044. */
  19045. color2: Color4;
  19046. /**
  19047. * Color the particle will have at the end of its lifetime.
  19048. */
  19049. colorDead: Color4;
  19050. /**
  19051. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  19052. */
  19053. textureMask: Color4;
  19054. /**
  19055. * The particle emitter type defines the emitter used by the particle system.
  19056. * It can be for example box, sphere, or cone...
  19057. */
  19058. particleEmitterType: IParticleEmitterType;
  19059. /**
  19060. * This function can be defined to specify initial direction for every new particle.
  19061. * It by default use the emitterType defined function.
  19062. */
  19063. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19064. /**
  19065. * This function can be defined to specify initial position for every new particle.
  19066. * It by default use the emitterType defined function.
  19067. */
  19068. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19069. /**
  19070. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  19071. */
  19072. spriteCellLoop: boolean;
  19073. /**
  19074. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  19075. */
  19076. spriteCellChangeSpeed: number;
  19077. /**
  19078. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  19079. */
  19080. startSpriteCellID: number;
  19081. /**
  19082. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  19083. */
  19084. endSpriteCellID: number;
  19085. /**
  19086. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  19087. */
  19088. spriteCellWidth: number;
  19089. /**
  19090. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  19091. */
  19092. spriteCellHeight: number;
  19093. /**
  19094. * An event triggered when the system is disposed.
  19095. */
  19096. onDisposeObservable: Observable<ParticleSystem>;
  19097. private _onDisposeObserver;
  19098. /**
  19099. * Sets a callback that will be triggered when the system is disposed.
  19100. */
  19101. onDispose: () => void;
  19102. /**
  19103. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  19104. */
  19105. readonly isAnimationSheetEnabled: Boolean;
  19106. private _particles;
  19107. private _epsilon;
  19108. private _capacity;
  19109. private _scene;
  19110. private _stockParticles;
  19111. private _newPartsExcess;
  19112. private _vertexData;
  19113. private _vertexBuffer;
  19114. private _vertexBuffers;
  19115. private _indexBuffer;
  19116. private _effect;
  19117. private _customEffect;
  19118. private _cachedDefines;
  19119. private _scaledColorStep;
  19120. private _colorDiff;
  19121. private _scaledDirection;
  19122. private _scaledGravity;
  19123. private _currentRenderId;
  19124. private _alive;
  19125. private _started;
  19126. private _stopped;
  19127. private _actualFrame;
  19128. private _scaledUpdateSpeed;
  19129. private _vertexBufferSize;
  19130. private _isAnimationSheetEnabled;
  19131. /**
  19132. * 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.
  19133. */
  19134. subEmitters: ParticleSystem[];
  19135. /**
  19136. * The current active Sub-systems, this property is used by the root particle system only.
  19137. */
  19138. activeSubSystems: Array<ParticleSystem>;
  19139. private _rootParticleSystem;
  19140. /**
  19141. * Gets the current list of active particles
  19142. */
  19143. readonly particles: Particle[];
  19144. /**
  19145. * Returns the string "ParticleSystem"
  19146. * @returns a string containing the class name
  19147. */
  19148. getClassName(): string;
  19149. /**
  19150. * Instantiates a particle system.
  19151. * 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.
  19152. * @param name The name of the particle system
  19153. * @param capacity The max number of particles alive at the same time
  19154. * @param scene The scene the particle system belongs to
  19155. * @param customEffect a custom effect used to change the way particles are rendered by default
  19156. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19157. * @param epsilon Offset used to render the particles
  19158. */
  19159. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19160. private _createIndexBuffer();
  19161. /**
  19162. * Gets the maximum number of particles active at the same time.
  19163. * @returns The max number of active particles.
  19164. */
  19165. getCapacity(): number;
  19166. /**
  19167. * Gets Wether there are still active particles in the system.
  19168. * @returns True if it is alive, otherwise false.
  19169. */
  19170. isAlive(): boolean;
  19171. /**
  19172. * Gets Wether the system has been started.
  19173. * @returns True if it has been started, otherwise false.
  19174. */
  19175. isStarted(): boolean;
  19176. /**
  19177. * Starts the particle system and begins to emit.
  19178. */
  19179. start(): void;
  19180. /**
  19181. * Stops the particle system.
  19182. * @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.
  19183. */
  19184. stop(stopSubEmitters?: boolean): void;
  19185. /**
  19186. * Remove all active particles
  19187. */
  19188. reset(): void;
  19189. /**
  19190. * @hidden (for internal use only)
  19191. */
  19192. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19193. /**
  19194. * @hidden (for internal use only)
  19195. */
  19196. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19197. /**
  19198. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19199. * Its lifetime will start back at 0.
  19200. */
  19201. recycleParticle: (particle: Particle) => void;
  19202. private _stopSubEmitters();
  19203. private _createParticle;
  19204. private _removeFromRoot();
  19205. private _emitFromParticle;
  19206. private _update(newParticles);
  19207. private _getEffect();
  19208. /**
  19209. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19210. */
  19211. animate(): void;
  19212. private _appendParticleVertexes;
  19213. private _appenedParticleVertexesWithSheet(offset, particle);
  19214. private _appenedParticleVertexesNoSheet(offset, particle);
  19215. /**
  19216. * Rebuilds the particle system.
  19217. */
  19218. rebuild(): void;
  19219. /**
  19220. * Is this system ready to be used/rendered
  19221. * @return true if the system is ready
  19222. */
  19223. isReady(): boolean;
  19224. /**
  19225. * Renders the particle system in its current state.
  19226. * @returns the current number of particles
  19227. */
  19228. render(): number;
  19229. /**
  19230. * Disposes the particle system and free the associated resources
  19231. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19232. */
  19233. dispose(disposeTexture?: boolean): void;
  19234. /**
  19235. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  19236. * @param radius The radius of the sphere to emit from
  19237. * @returns the emitter
  19238. */
  19239. createSphereEmitter(radius?: number): SphereParticleEmitter;
  19240. /**
  19241. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  19242. * @param radius The radius of the sphere to emit from
  19243. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19244. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19245. * @returns the emitter
  19246. */
  19247. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19248. /**
  19249. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  19250. * @param radius The radius of the cone to emit from
  19251. * @param angle The base angle of the cone
  19252. * @returns the emitter
  19253. */
  19254. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19255. /**
  19256. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19257. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19258. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19259. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19260. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19261. * @returns the emitter
  19262. */
  19263. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19264. /**
  19265. * Clones the particle system.
  19266. * @param name The name of the cloned object
  19267. * @param newEmitter The new emitter to use
  19268. * @returns the cloned particle system
  19269. */
  19270. clone(name: string, newEmitter: any): ParticleSystem;
  19271. /**
  19272. * Serializes the particle system to a JSON object.
  19273. * @returns the JSON object
  19274. */
  19275. serialize(): any;
  19276. /**
  19277. * Parses a JSON object to create a particle system.
  19278. * @param parsedParticleSystem The JSON object to parse
  19279. * @param scene The scene to create the particle system in
  19280. * @param rootUrl The root url to use to load external dependencies like texture
  19281. * @returns the Parsed particle system
  19282. */
  19283. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  19284. }
  19285. }
  19286. declare module BABYLON {
  19287. /**
  19288. * Represents one particle of a solid particle system.
  19289. */
  19290. class SolidParticle {
  19291. /**
  19292. * particle global index
  19293. */
  19294. idx: number;
  19295. /**
  19296. * The color of the particle
  19297. */
  19298. color: Nullable<Color4>;
  19299. /**
  19300. * The world space position of the particle.
  19301. */
  19302. position: Vector3;
  19303. /**
  19304. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  19305. */
  19306. rotation: Vector3;
  19307. /**
  19308. * The world space rotation quaternion of the particle.
  19309. */
  19310. rotationQuaternion: Nullable<Quaternion>;
  19311. /**
  19312. * The scaling of the particle.
  19313. */
  19314. scaling: Vector3;
  19315. /**
  19316. * The uvs of the particle.
  19317. */
  19318. uvs: Vector4;
  19319. /**
  19320. * The current speed of the particle.
  19321. */
  19322. velocity: Vector3;
  19323. /**
  19324. * The pivot point in the particle local space.
  19325. */
  19326. pivot: Vector3;
  19327. /**
  19328. * Must the particle be translated from its pivot point in its local space ?
  19329. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  19330. * Default : false
  19331. */
  19332. translateFromPivot: boolean;
  19333. /**
  19334. * Is the particle active or not ?
  19335. */
  19336. alive: boolean;
  19337. /**
  19338. * Is the particle visible or not ?
  19339. */
  19340. isVisible: boolean;
  19341. /**
  19342. * Index of this particle in the global "positions" array (Internal use)
  19343. */
  19344. _pos: number;
  19345. /**
  19346. * Index of this particle in the global "indices" array (Internal use)
  19347. */
  19348. _ind: number;
  19349. /**
  19350. * ModelShape of this particle (Internal use)
  19351. */
  19352. _model: ModelShape;
  19353. /**
  19354. * ModelShape id of this particle
  19355. */
  19356. shapeId: number;
  19357. /**
  19358. * Index of the particle in its shape id (Internal use)
  19359. */
  19360. idxInShape: number;
  19361. /**
  19362. * Reference to the shape model BoundingInfo object (Internal use)
  19363. */
  19364. _modelBoundingInfo: BoundingInfo;
  19365. /**
  19366. * Particle BoundingInfo object (Internal use)
  19367. */
  19368. _boundingInfo: BoundingInfo;
  19369. /**
  19370. * Reference to the SPS what the particle belongs to (Internal use)
  19371. */
  19372. _sps: SolidParticleSystem;
  19373. /**
  19374. * Still set as invisible in order to skip useless computations (Internal use)
  19375. */
  19376. _stillInvisible: boolean;
  19377. /**
  19378. * Last computed particle rotation matrix
  19379. */
  19380. _rotationMatrix: number[];
  19381. /**
  19382. * Parent particle Id, if any.
  19383. * Default null.
  19384. */
  19385. parentId: Nullable<number>;
  19386. /**
  19387. * Internal global position in the SPS.
  19388. */
  19389. _globalPosition: Vector3;
  19390. /**
  19391. * Creates a Solid Particle object.
  19392. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  19393. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  19394. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  19395. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  19396. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  19397. * @param shapeId (integer) is the model shape identifier in the SPS.
  19398. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  19399. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  19400. */
  19401. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  19402. /**
  19403. * Legacy support, changed scale to scaling
  19404. */
  19405. /**
  19406. * Legacy support, changed scale to scaling
  19407. */
  19408. scale: Vector3;
  19409. /**
  19410. * Legacy support, changed quaternion to rotationQuaternion
  19411. */
  19412. /**
  19413. * Legacy support, changed quaternion to rotationQuaternion
  19414. */
  19415. quaternion: Nullable<Quaternion>;
  19416. /**
  19417. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  19418. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  19419. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  19420. * @returns true if it intersects
  19421. */
  19422. intersectsMesh(target: Mesh | SolidParticle): boolean;
  19423. }
  19424. /**
  19425. * Represents the shape of the model used by one particle of a solid particle system.
  19426. * SPS internal tool, don't use it manually.
  19427. */
  19428. class ModelShape {
  19429. /**
  19430. * The shape id.
  19431. */
  19432. shapeID: number;
  19433. /**
  19434. * flat array of model positions (internal use)
  19435. */
  19436. _shape: Vector3[];
  19437. /**
  19438. * flat array of model UVs (internal use)
  19439. */
  19440. _shapeUV: number[];
  19441. /**
  19442. * length of the shape in the model indices array (internal use)
  19443. */
  19444. _indicesLength: number;
  19445. /**
  19446. * Custom position function (internal use)
  19447. */
  19448. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  19449. /**
  19450. * Custom vertex function (internal use)
  19451. */
  19452. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  19453. /**
  19454. * 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.
  19455. * SPS internal tool, don't use it manually.
  19456. * @hidden
  19457. */
  19458. 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>);
  19459. }
  19460. /**
  19461. * Represents a Depth Sorted Particle in the solid particle system.
  19462. */
  19463. class DepthSortedParticle {
  19464. /**
  19465. * Index of the particle in the "indices" array
  19466. */
  19467. ind: number;
  19468. /**
  19469. * Length of the particle shape in the "indices" array
  19470. */
  19471. indicesLength: number;
  19472. /**
  19473. * Squared distance from the particle to the camera
  19474. */
  19475. sqDistance: number;
  19476. }
  19477. }
  19478. declare module BABYLON {
  19479. /**
  19480. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  19481. *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.
  19482. * The SPS is also a particle system. It provides some methods to manage the particles.
  19483. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  19484. *
  19485. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  19486. */
  19487. class SolidParticleSystem implements IDisposable {
  19488. /**
  19489. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  19490. * Example : var p = SPS.particles[i];
  19491. */
  19492. particles: SolidParticle[];
  19493. /**
  19494. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  19495. */
  19496. nbParticles: number;
  19497. /**
  19498. * If the particles must ever face the camera (default false). Useful for planar particles.
  19499. */
  19500. billboard: boolean;
  19501. /**
  19502. * Recompute normals when adding a shape
  19503. */
  19504. recomputeNormals: boolean;
  19505. /**
  19506. * This a counter ofr your own usage. It's not set by any SPS functions.
  19507. */
  19508. counter: number;
  19509. /**
  19510. * The SPS name. This name is also given to the underlying mesh.
  19511. */
  19512. name: string;
  19513. /**
  19514. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  19515. */
  19516. mesh: Mesh;
  19517. /**
  19518. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  19519. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  19520. */
  19521. vars: any;
  19522. /**
  19523. * This array is populated when the SPS is set as 'pickable'.
  19524. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  19525. * Each element of this array is an object `{idx: int, faceId: int}`.
  19526. * `idx` is the picked particle index in the `SPS.particles` array
  19527. * `faceId` is the picked face index counted within this particle.
  19528. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  19529. */
  19530. pickedParticles: {
  19531. idx: number;
  19532. faceId: number;
  19533. }[];
  19534. /**
  19535. * This array is populated when `enableDepthSort` is set to true.
  19536. * Each element of this array is an instance of the class DepthSortedParticle.
  19537. */
  19538. depthSortedParticles: DepthSortedParticle[];
  19539. /**
  19540. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  19541. */
  19542. _bSphereOnly: boolean;
  19543. /**
  19544. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  19545. */
  19546. _bSphereRadiusFactor: number;
  19547. private _scene;
  19548. private _positions;
  19549. private _indices;
  19550. private _normals;
  19551. private _colors;
  19552. private _uvs;
  19553. private _indices32;
  19554. private _positions32;
  19555. private _normals32;
  19556. private _fixedNormal32;
  19557. private _colors32;
  19558. private _uvs32;
  19559. private _index;
  19560. private _updatable;
  19561. private _pickable;
  19562. private _isVisibilityBoxLocked;
  19563. private _alwaysVisible;
  19564. private _depthSort;
  19565. private _shapeCounter;
  19566. private _copy;
  19567. private _shape;
  19568. private _shapeUV;
  19569. private _color;
  19570. private _computeParticleColor;
  19571. private _computeParticleTexture;
  19572. private _computeParticleRotation;
  19573. private _computeParticleVertex;
  19574. private _computeBoundingBox;
  19575. private _depthSortParticles;
  19576. private _cam_axisZ;
  19577. private _cam_axisY;
  19578. private _cam_axisX;
  19579. private _axisZ;
  19580. private _camera;
  19581. private _particle;
  19582. private _camDir;
  19583. private _camInvertedPosition;
  19584. private _rotMatrix;
  19585. private _invertMatrix;
  19586. private _rotated;
  19587. private _quaternion;
  19588. private _vertex;
  19589. private _normal;
  19590. private _yaw;
  19591. private _pitch;
  19592. private _roll;
  19593. private _halfroll;
  19594. private _halfpitch;
  19595. private _halfyaw;
  19596. private _sinRoll;
  19597. private _cosRoll;
  19598. private _sinPitch;
  19599. private _cosPitch;
  19600. private _sinYaw;
  19601. private _cosYaw;
  19602. private _mustUnrotateFixedNormals;
  19603. private _minimum;
  19604. private _maximum;
  19605. private _minBbox;
  19606. private _maxBbox;
  19607. private _particlesIntersect;
  19608. private _depthSortFunction;
  19609. private _needs32Bits;
  19610. private _pivotBackTranslation;
  19611. private _scaledPivot;
  19612. private _particleHasParent;
  19613. private _parent;
  19614. /**
  19615. * Creates a SPS (Solid Particle System) object.
  19616. * @param name (String) is the SPS name, this will be the underlying mesh name.
  19617. * @param scene (Scene) is the scene in which the SPS is added.
  19618. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  19619. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  19620. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  19621. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  19622. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  19623. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  19624. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  19625. */
  19626. constructor(name: string, scene: Scene, options?: {
  19627. updatable?: boolean;
  19628. isPickable?: boolean;
  19629. enableDepthSort?: boolean;
  19630. particleIntersection?: boolean;
  19631. boundingSphereOnly?: boolean;
  19632. bSphereRadiusFactor?: number;
  19633. });
  19634. /**
  19635. * Builds the SPS underlying mesh. Returns a standard Mesh.
  19636. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  19637. * @returns the created mesh
  19638. */
  19639. buildMesh(): Mesh;
  19640. /**
  19641. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  19642. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  19643. * Thus the particles generated from `digest()` have their property `position` set yet.
  19644. * @param mesh ( Mesh ) is the mesh to be digested
  19645. * @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
  19646. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  19647. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  19648. * @returns the current SPS
  19649. */
  19650. digest(mesh: Mesh, options?: {
  19651. facetNb?: number;
  19652. number?: number;
  19653. delta?: number;
  19654. }): SolidParticleSystem;
  19655. private _unrotateFixedNormals();
  19656. private _resetCopy();
  19657. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  19658. private _posToShape(positions);
  19659. private _uvsToShapeUV(uvs);
  19660. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  19661. /**
  19662. * Adds some particles to the SPS from the model shape. Returns the shape id.
  19663. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  19664. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  19665. * @param nb (positive integer) the number of particles to be created from this model
  19666. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  19667. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  19668. * @returns the number of shapes in the system
  19669. */
  19670. addShape(mesh: Mesh, nb: number, options?: {
  19671. positionFunction?: any;
  19672. vertexFunction?: any;
  19673. }): number;
  19674. private _rebuildParticle(particle);
  19675. /**
  19676. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  19677. * @returns the SPS.
  19678. */
  19679. rebuildMesh(): SolidParticleSystem;
  19680. /**
  19681. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  19682. * This method calls `updateParticle()` for each particle of the SPS.
  19683. * For an animated SPS, it is usually called within the render loop.
  19684. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  19685. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  19686. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  19687. * @returns the SPS.
  19688. */
  19689. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  19690. private _quaternionRotationYPR();
  19691. private _quaternionToRotationMatrix();
  19692. /**
  19693. * Disposes the SPS.
  19694. */
  19695. dispose(): void;
  19696. /**
  19697. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  19698. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19699. * @returns the SPS.
  19700. */
  19701. refreshVisibleSize(): SolidParticleSystem;
  19702. /**
  19703. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  19704. * @param size the size (float) of the visibility box
  19705. * note : this doesn't lock the SPS mesh bounding box.
  19706. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19707. */
  19708. setVisibilityBox(size: number): void;
  19709. /**
  19710. * Gets whether the SPS as always visible or not
  19711. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19712. */
  19713. /**
  19714. * Sets the SPS as always visible or not
  19715. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19716. */
  19717. isAlwaysVisible: boolean;
  19718. /**
  19719. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19720. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19721. */
  19722. /**
  19723. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19724. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19725. */
  19726. isVisibilityBoxLocked: boolean;
  19727. /**
  19728. * Gets if `setParticles()` computes the particle rotations or not.
  19729. * Default value : true. The SPS is faster when it's set to false.
  19730. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19731. */
  19732. /**
  19733. * Tells to `setParticles()` to compute the particle rotations or not.
  19734. * Default value : true. The SPS is faster when it's set to false.
  19735. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19736. */
  19737. computeParticleRotation: boolean;
  19738. /**
  19739. * Gets if `setParticles()` computes the particle colors or not.
  19740. * Default value : true. The SPS is faster when it's set to false.
  19741. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19742. */
  19743. /**
  19744. * Tells to `setParticles()` to compute the particle colors or not.
  19745. * Default value : true. The SPS is faster when it's set to false.
  19746. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19747. */
  19748. computeParticleColor: boolean;
  19749. /**
  19750. * Gets if `setParticles()` computes the particle textures or not.
  19751. * Default value : true. The SPS is faster when it's set to false.
  19752. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19753. */
  19754. computeParticleTexture: boolean;
  19755. /**
  19756. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19757. * Default value : false. The SPS is faster when it's set to false.
  19758. * Note : the particle custom vertex positions aren't stored values.
  19759. */
  19760. /**
  19761. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19762. * Default value : false. The SPS is faster when it's set to false.
  19763. * Note : the particle custom vertex positions aren't stored values.
  19764. */
  19765. computeParticleVertex: boolean;
  19766. /**
  19767. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19768. */
  19769. /**
  19770. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19771. */
  19772. computeBoundingBox: boolean;
  19773. /**
  19774. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19775. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19776. * Default : `true`
  19777. */
  19778. /**
  19779. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19780. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19781. * Default : `true`
  19782. */
  19783. depthSortParticles: boolean;
  19784. /**
  19785. * This function does nothing. It may be overwritten to set all the particle first values.
  19786. * The SPS doesn't call this function, you may have to call it by your own.
  19787. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19788. */
  19789. initParticles(): void;
  19790. /**
  19791. * This function does nothing. It may be overwritten to recycle a particle.
  19792. * The SPS doesn't call this function, you may have to call it by your own.
  19793. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19794. * @param particle The particle to recycle
  19795. * @returns the recycled particle
  19796. */
  19797. recycleParticle(particle: SolidParticle): SolidParticle;
  19798. /**
  19799. * Updates a particle : this function should be overwritten by the user.
  19800. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  19801. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19802. * @example : just set a particle position or velocity and recycle conditions
  19803. * @param particle The particle to update
  19804. * @returns the updated particle
  19805. */
  19806. updateParticle(particle: SolidParticle): SolidParticle;
  19807. /**
  19808. * Updates a vertex of a particle : it can be overwritten by the user.
  19809. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  19810. * @param particle the current particle
  19811. * @param vertex the current index of the current particle
  19812. * @param pt the index of the current vertex in the particle shape
  19813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  19814. * @example : just set a vertex particle position
  19815. * @returns the updated vertex
  19816. */
  19817. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  19818. /**
  19819. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  19820. * This does nothing and may be overwritten by the user.
  19821. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19822. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19823. * @param update the boolean update value actually passed to setParticles()
  19824. */
  19825. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19826. /**
  19827. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19828. * This will be passed three parameters.
  19829. * This does nothing and may be overwritten by the user.
  19830. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19831. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19832. * @param update the boolean update value actually passed to setParticles()
  19833. */
  19834. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19835. }
  19836. }
  19837. declare module BABYLON {
  19838. interface PhysicsImpostorJoint {
  19839. mainImpostor: PhysicsImpostor;
  19840. connectedImpostor: PhysicsImpostor;
  19841. joint: PhysicsJoint;
  19842. }
  19843. class PhysicsEngine {
  19844. private _physicsPlugin;
  19845. gravity: Vector3;
  19846. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  19847. setGravity(gravity: Vector3): void;
  19848. /**
  19849. * Set the time step of the physics engine.
  19850. * default is 1/60.
  19851. * To slow it down, enter 1/600 for example.
  19852. * To speed it up, 1/30
  19853. * @param {number} newTimeStep the new timestep to apply to this world.
  19854. */
  19855. setTimeStep(newTimeStep?: number): void;
  19856. /**
  19857. * Get the time step of the physics engine.
  19858. */
  19859. getTimeStep(): number;
  19860. dispose(): void;
  19861. getPhysicsPluginName(): string;
  19862. static Epsilon: number;
  19863. private _impostors;
  19864. private _joints;
  19865. /**
  19866. * Adding a new impostor for the impostor tracking.
  19867. * This will be done by the impostor itself.
  19868. * @param {PhysicsImpostor} impostor the impostor to add
  19869. */
  19870. addImpostor(impostor: PhysicsImpostor): void;
  19871. /**
  19872. * Remove an impostor from the engine.
  19873. * This impostor and its mesh will not longer be updated by the physics engine.
  19874. * @param {PhysicsImpostor} impostor the impostor to remove
  19875. */
  19876. removeImpostor(impostor: PhysicsImpostor): void;
  19877. /**
  19878. * Add a joint to the physics engine
  19879. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  19880. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  19881. * @param {PhysicsJoint} the joint that will connect both impostors.
  19882. */
  19883. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19884. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19885. /**
  19886. * Called by the scene. no need to call it.
  19887. */
  19888. _step(delta: number): void;
  19889. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19890. getImpostors(): Array<PhysicsImpostor>;
  19891. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19892. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19893. }
  19894. interface IPhysicsEnginePlugin {
  19895. world: any;
  19896. name: string;
  19897. setGravity(gravity: Vector3): void;
  19898. setTimeStep(timeStep: number): void;
  19899. getTimeStep(): number;
  19900. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19901. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19902. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19903. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19904. removePhysicsBody(impostor: PhysicsImpostor): void;
  19905. generateJoint(joint: PhysicsImpostorJoint): void;
  19906. removeJoint(joint: PhysicsImpostorJoint): void;
  19907. isSupported(): boolean;
  19908. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19909. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19910. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19911. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19912. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19913. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19914. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19915. getBodyMass(impostor: PhysicsImpostor): number;
  19916. getBodyFriction(impostor: PhysicsImpostor): number;
  19917. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19918. getBodyRestitution(impostor: PhysicsImpostor): number;
  19919. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19920. sleepBody(impostor: PhysicsImpostor): void;
  19921. wakeUpBody(impostor: PhysicsImpostor): void;
  19922. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19923. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19924. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19925. getRadius(impostor: PhysicsImpostor): number;
  19926. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19927. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19928. dispose(): void;
  19929. }
  19930. }
  19931. declare module BABYLON {
  19932. class PhysicsHelper {
  19933. private _scene;
  19934. private _physicsEngine;
  19935. constructor(scene: Scene);
  19936. /**
  19937. * @param {Vector3} origin the origin of the explosion
  19938. * @param {number} radius the explosion radius
  19939. * @param {number} strength the explosion strength
  19940. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19941. */
  19942. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19943. /**
  19944. * @param {Vector3} origin the origin of the explosion
  19945. * @param {number} radius the explosion radius
  19946. * @param {number} strength the explosion strength
  19947. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19948. */
  19949. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19950. /**
  19951. * @param {Vector3} origin the origin of the explosion
  19952. * @param {number} radius the explosion radius
  19953. * @param {number} strength the explosion strength
  19954. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19955. */
  19956. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  19957. /**
  19958. * @param {Vector3} origin the origin of the updraft
  19959. * @param {number} radius the radius of the updraft
  19960. * @param {number} strength the strength of the updraft
  19961. * @param {number} height the height of the updraft
  19962. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  19963. */
  19964. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  19965. /**
  19966. * @param {Vector3} origin the of the vortex
  19967. * @param {number} radius the radius of the vortex
  19968. * @param {number} strength the strength of the vortex
  19969. * @param {number} height the height of the vortex
  19970. */
  19971. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  19972. }
  19973. /***** Radial explosion *****/
  19974. class PhysicsRadialExplosionEvent {
  19975. private _scene;
  19976. private _sphere;
  19977. private _sphereOptions;
  19978. private _rays;
  19979. private _dataFetched;
  19980. constructor(scene: Scene);
  19981. /**
  19982. * Returns the data related to the radial explosion event (sphere & rays).
  19983. * @returns {PhysicsRadialExplosionEventData}
  19984. */
  19985. getData(): PhysicsRadialExplosionEventData;
  19986. /**
  19987. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  19988. * @param impostor
  19989. * @param {Vector3} origin the origin of the explosion
  19990. * @param {number} radius the explosion radius
  19991. * @param {number} strength the explosion strength
  19992. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  19993. * @returns {Nullable<PhysicsForceAndContactPoint>}
  19994. */
  19995. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  19996. /**
  19997. * Disposes the sphere.
  19998. * @param {bolean} force
  19999. */
  20000. dispose(force?: boolean): void;
  20001. /*** Helpers ***/
  20002. private _prepareSphere();
  20003. private _intersectsWithSphere(impostor, origin, radius);
  20004. }
  20005. /***** Gravitational Field *****/
  20006. class PhysicsGravitationalFieldEvent {
  20007. private _physicsHelper;
  20008. private _scene;
  20009. private _origin;
  20010. private _radius;
  20011. private _strength;
  20012. private _falloff;
  20013. private _tickCallback;
  20014. private _sphere;
  20015. private _dataFetched;
  20016. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  20017. /**
  20018. * Returns the data related to the gravitational field event (sphere).
  20019. * @returns {PhysicsGravitationalFieldEventData}
  20020. */
  20021. getData(): PhysicsGravitationalFieldEventData;
  20022. /**
  20023. * Enables the gravitational field.
  20024. */
  20025. enable(): void;
  20026. /**
  20027. * Disables the gravitational field.
  20028. */
  20029. disable(): void;
  20030. /**
  20031. * Disposes the sphere.
  20032. * @param {bolean} force
  20033. */
  20034. dispose(force?: boolean): void;
  20035. private _tick();
  20036. }
  20037. /***** Updraft *****/
  20038. class PhysicsUpdraftEvent {
  20039. private _scene;
  20040. private _origin;
  20041. private _radius;
  20042. private _strength;
  20043. private _height;
  20044. private _updraftMode;
  20045. private _physicsEngine;
  20046. private _originTop;
  20047. private _originDirection;
  20048. private _tickCallback;
  20049. private _cylinder;
  20050. private _cylinderPosition;
  20051. private _dataFetched;
  20052. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  20053. /**
  20054. * Returns the data related to the updraft event (cylinder).
  20055. * @returns {PhysicsUpdraftEventData}
  20056. */
  20057. getData(): PhysicsUpdraftEventData;
  20058. /**
  20059. * Enables the updraft.
  20060. */
  20061. enable(): void;
  20062. /**
  20063. * Disables the cortex.
  20064. */
  20065. disable(): void;
  20066. /**
  20067. * Disposes the sphere.
  20068. * @param {bolean} force
  20069. */
  20070. dispose(force?: boolean): void;
  20071. private getImpostorForceAndContactPoint(impostor);
  20072. private _tick();
  20073. /*** Helpers ***/
  20074. private _prepareCylinder();
  20075. private _intersectsWithCylinder(impostor);
  20076. }
  20077. /***** Vortex *****/
  20078. class PhysicsVortexEvent {
  20079. private _scene;
  20080. private _origin;
  20081. private _radius;
  20082. private _strength;
  20083. private _height;
  20084. private _physicsEngine;
  20085. private _originTop;
  20086. private _centripetalForceThreshold;
  20087. private _updraftMultiplier;
  20088. private _tickCallback;
  20089. private _cylinder;
  20090. private _cylinderPosition;
  20091. private _dataFetched;
  20092. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  20093. /**
  20094. * Returns the data related to the vortex event (cylinder).
  20095. * @returns {PhysicsVortexEventData}
  20096. */
  20097. getData(): PhysicsVortexEventData;
  20098. /**
  20099. * Enables the vortex.
  20100. */
  20101. enable(): void;
  20102. /**
  20103. * Disables the cortex.
  20104. */
  20105. disable(): void;
  20106. /**
  20107. * Disposes the sphere.
  20108. * @param {bolean} force
  20109. */
  20110. dispose(force?: boolean): void;
  20111. private getImpostorForceAndContactPoint(impostor);
  20112. private _tick();
  20113. /*** Helpers ***/
  20114. private _prepareCylinder();
  20115. private _intersectsWithCylinder(impostor);
  20116. }
  20117. /***** Enums *****/
  20118. /**
  20119. * The strenght of the force in correspondence to the distance of the affected object
  20120. */
  20121. enum PhysicsRadialImpulseFalloff {
  20122. /** Defines that impulse is constant in strength across it's whole radius */
  20123. Constant = 0,
  20124. /** DEfines that impulse gets weaker if it's further from the origin */
  20125. Linear = 1,
  20126. }
  20127. /**
  20128. * The strenght of the force in correspondence to the distance of the affected object
  20129. */
  20130. enum PhysicsUpdraftMode {
  20131. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  20132. Center = 0,
  20133. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  20134. Perpendicular = 1,
  20135. }
  20136. /***** Data interfaces *****/
  20137. interface PhysicsForceAndContactPoint {
  20138. force: Vector3;
  20139. contactPoint: Vector3;
  20140. }
  20141. interface PhysicsRadialExplosionEventData {
  20142. sphere: Mesh;
  20143. rays: Array<Ray>;
  20144. }
  20145. interface PhysicsGravitationalFieldEventData {
  20146. sphere: Mesh;
  20147. }
  20148. interface PhysicsUpdraftEventData {
  20149. cylinder: Mesh;
  20150. }
  20151. interface PhysicsVortexEventData {
  20152. cylinder: Mesh;
  20153. }
  20154. }
  20155. declare module BABYLON {
  20156. interface PhysicsImpostorParameters {
  20157. mass: number;
  20158. friction?: number;
  20159. restitution?: number;
  20160. nativeOptions?: any;
  20161. ignoreParent?: boolean;
  20162. disableBidirectionalTransformation?: boolean;
  20163. }
  20164. interface IPhysicsEnabledObject {
  20165. position: Vector3;
  20166. rotationQuaternion: Nullable<Quaternion>;
  20167. scaling: Vector3;
  20168. rotation?: Vector3;
  20169. parent?: any;
  20170. getBoundingInfo(): BoundingInfo;
  20171. computeWorldMatrix(force: boolean): Matrix;
  20172. getWorldMatrix?(): Matrix;
  20173. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20174. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20175. getIndices?(): Nullable<IndicesArray>;
  20176. getScene?(): Scene;
  20177. getAbsolutePosition(): Vector3;
  20178. getAbsolutePivotPoint(): Vector3;
  20179. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20180. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20181. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20182. getClassName(): string;
  20183. }
  20184. class PhysicsImpostor {
  20185. object: IPhysicsEnabledObject;
  20186. type: number;
  20187. private _options;
  20188. private _scene;
  20189. static DEFAULT_OBJECT_SIZE: Vector3;
  20190. static IDENTITY_QUATERNION: Quaternion;
  20191. private _physicsEngine;
  20192. private _physicsBody;
  20193. private _bodyUpdateRequired;
  20194. private _onBeforePhysicsStepCallbacks;
  20195. private _onAfterPhysicsStepCallbacks;
  20196. private _onPhysicsCollideCallbacks;
  20197. private _deltaPosition;
  20198. private _deltaRotation;
  20199. private _deltaRotationConjugated;
  20200. private _parent;
  20201. private _isDisposed;
  20202. private static _tmpVecs;
  20203. private static _tmpQuat;
  20204. readonly isDisposed: boolean;
  20205. mass: number;
  20206. friction: number;
  20207. restitution: number;
  20208. uniqueId: number;
  20209. private _joints;
  20210. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20211. /**
  20212. * This function will completly initialize this impostor.
  20213. * It will create a new body - but only if this mesh has no parent.
  20214. * If it has, this impostor will not be used other than to define the impostor
  20215. * of the child mesh.
  20216. */
  20217. _init(): void;
  20218. private _getPhysicsParent();
  20219. /**
  20220. * Should a new body be generated.
  20221. */
  20222. isBodyInitRequired(): boolean;
  20223. setScalingUpdated(updated: boolean): void;
  20224. /**
  20225. * Force a regeneration of this or the parent's impostor's body.
  20226. * Use under cautious - This will remove all joints already implemented.
  20227. */
  20228. forceUpdate(): void;
  20229. /**
  20230. * Gets the body that holds this impostor. Either its own, or its parent.
  20231. */
  20232. /**
  20233. * Set the physics body. Used mainly by the physics engine/plugin
  20234. */
  20235. physicsBody: any;
  20236. parent: Nullable<PhysicsImpostor>;
  20237. resetUpdateFlags(): void;
  20238. getObjectExtendSize(): Vector3;
  20239. getObjectCenter(): Vector3;
  20240. /**
  20241. * Get a specific parametes from the options parameter.
  20242. */
  20243. getParam(paramName: string): any;
  20244. /**
  20245. * Sets a specific parameter in the options given to the physics plugin
  20246. */
  20247. setParam(paramName: string, value: number): void;
  20248. /**
  20249. * Specifically change the body's mass option. Won't recreate the physics body object
  20250. */
  20251. setMass(mass: number): void;
  20252. getLinearVelocity(): Nullable<Vector3>;
  20253. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20254. getAngularVelocity(): Nullable<Vector3>;
  20255. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20256. /**
  20257. * Execute a function with the physics plugin native code.
  20258. * Provide a function the will have two variables - the world object and the physics body object.
  20259. */
  20260. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20261. /**
  20262. * Register a function that will be executed before the physics world is stepping forward.
  20263. */
  20264. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20265. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20266. /**
  20267. * Register a function that will be executed after the physics step
  20268. */
  20269. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20270. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20271. /**
  20272. * register a function that will be executed when this impostor collides against a different body.
  20273. */
  20274. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20275. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20276. private _tmpQuat;
  20277. private _tmpQuat2;
  20278. getParentsRotation(): Quaternion;
  20279. /**
  20280. * this function is executed by the physics engine.
  20281. */
  20282. beforeStep: () => void;
  20283. /**
  20284. * this function is executed by the physics engine.
  20285. */
  20286. afterStep: () => void;
  20287. /**
  20288. * Legacy collision detection event support
  20289. */
  20290. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20291. onCollide: (e: {
  20292. body: any;
  20293. }) => void;
  20294. /**
  20295. * Apply a force
  20296. */
  20297. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20298. /**
  20299. * Apply an impulse
  20300. */
  20301. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20302. /**
  20303. * A help function to create a joint.
  20304. */
  20305. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20306. /**
  20307. * Add a joint to this impostor with a different impostor.
  20308. */
  20309. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20310. /**
  20311. * Will keep this body still, in a sleep mode.
  20312. */
  20313. sleep(): PhysicsImpostor;
  20314. /**
  20315. * Wake the body up.
  20316. */
  20317. wakeUp(): PhysicsImpostor;
  20318. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20319. dispose(): void;
  20320. setDeltaPosition(position: Vector3): void;
  20321. setDeltaRotation(rotation: Quaternion): void;
  20322. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20323. getRadius(): number;
  20324. /**
  20325. * Sync a bone with this impostor
  20326. * @param bone The bone to sync to the impostor.
  20327. * @param boneMesh The mesh that the bone is influencing.
  20328. * @param jointPivot The pivot of the joint / bone in local space.
  20329. * @param distToJoint Optional distance from the impostor to the joint.
  20330. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20331. */
  20332. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20333. /**
  20334. * Sync impostor to a bone
  20335. * @param bone The bone that the impostor will be synced to.
  20336. * @param boneMesh The mesh that the bone is influencing.
  20337. * @param jointPivot The pivot of the joint / bone in local space.
  20338. * @param distToJoint Optional distance from the impostor to the joint.
  20339. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20340. * @param boneAxis Optional vector3 axis the bone is aligned with
  20341. */
  20342. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20343. static NoImpostor: number;
  20344. static SphereImpostor: number;
  20345. static BoxImpostor: number;
  20346. static PlaneImpostor: number;
  20347. static MeshImpostor: number;
  20348. static CylinderImpostor: number;
  20349. static ParticleImpostor: number;
  20350. static HeightmapImpostor: number;
  20351. }
  20352. }
  20353. declare module BABYLON {
  20354. interface PhysicsJointData {
  20355. mainPivot?: Vector3;
  20356. connectedPivot?: Vector3;
  20357. mainAxis?: Vector3;
  20358. connectedAxis?: Vector3;
  20359. collision?: boolean;
  20360. nativeParams?: any;
  20361. }
  20362. /**
  20363. * This is a holder class for the physics joint created by the physics plugin.
  20364. * It holds a set of functions to control the underlying joint.
  20365. */
  20366. class PhysicsJoint {
  20367. type: number;
  20368. jointData: PhysicsJointData;
  20369. private _physicsJoint;
  20370. protected _physicsPlugin: IPhysicsEnginePlugin;
  20371. constructor(type: number, jointData: PhysicsJointData);
  20372. physicsJoint: any;
  20373. physicsPlugin: IPhysicsEnginePlugin;
  20374. /**
  20375. * Execute a function that is physics-plugin specific.
  20376. * @param {Function} func the function that will be executed.
  20377. * It accepts two parameters: the physics world and the physics joint.
  20378. */
  20379. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20380. static DistanceJoint: number;
  20381. static HingeJoint: number;
  20382. static BallAndSocketJoint: number;
  20383. static WheelJoint: number;
  20384. static SliderJoint: number;
  20385. static PrismaticJoint: number;
  20386. static UniversalJoint: number;
  20387. static Hinge2Joint: number;
  20388. static PointToPointJoint: number;
  20389. static SpringJoint: number;
  20390. static LockJoint: number;
  20391. }
  20392. /**
  20393. * A class representing a physics distance joint.
  20394. */
  20395. class DistanceJoint extends PhysicsJoint {
  20396. constructor(jointData: DistanceJointData);
  20397. /**
  20398. * Update the predefined distance.
  20399. */
  20400. updateDistance(maxDistance: number, minDistance?: number): void;
  20401. }
  20402. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20403. constructor(type: number, jointData: PhysicsJointData);
  20404. /**
  20405. * Set the motor values.
  20406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20407. * @param {number} force the force to apply
  20408. * @param {number} maxForce max force for this motor.
  20409. */
  20410. setMotor(force?: number, maxForce?: number): void;
  20411. /**
  20412. * Set the motor's limits.
  20413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20414. */
  20415. setLimit(upperLimit: number, lowerLimit?: number): void;
  20416. }
  20417. /**
  20418. * This class represents a single hinge physics joint
  20419. */
  20420. class HingeJoint extends MotorEnabledJoint {
  20421. constructor(jointData: PhysicsJointData);
  20422. /**
  20423. * Set the motor values.
  20424. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20425. * @param {number} force the force to apply
  20426. * @param {number} maxForce max force for this motor.
  20427. */
  20428. setMotor(force?: number, maxForce?: number): void;
  20429. /**
  20430. * Set the motor's limits.
  20431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20432. */
  20433. setLimit(upperLimit: number, lowerLimit?: number): void;
  20434. }
  20435. /**
  20436. * This class represents a dual hinge physics joint (same as wheel joint)
  20437. */
  20438. class Hinge2Joint extends MotorEnabledJoint {
  20439. constructor(jointData: PhysicsJointData);
  20440. /**
  20441. * Set the motor values.
  20442. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20443. * @param {number} force the force to apply
  20444. * @param {number} maxForce max force for this motor.
  20445. * @param {motorIndex} the motor's index, 0 or 1.
  20446. */
  20447. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20448. /**
  20449. * Set the motor limits.
  20450. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20451. * @param {number} upperLimit the upper limit
  20452. * @param {number} lowerLimit lower limit
  20453. * @param {motorIndex} the motor's index, 0 or 1.
  20454. */
  20455. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20456. }
  20457. interface IMotorEnabledJoint {
  20458. physicsJoint: any;
  20459. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20460. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20461. }
  20462. interface DistanceJointData extends PhysicsJointData {
  20463. maxDistance: number;
  20464. }
  20465. interface SpringJointData extends PhysicsJointData {
  20466. length: number;
  20467. stiffness: number;
  20468. damping: number;
  20469. }
  20470. }
  20471. declare module BABYLON {
  20472. /**
  20473. * Class used to store all common mesh properties
  20474. */
  20475. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  20476. /** No occlusion */
  20477. static OCCLUSION_TYPE_NONE: number;
  20478. /** Occlusion set to optimisitic */
  20479. static OCCLUSION_TYPE_OPTIMISTIC: number;
  20480. /** Occlusion set to strict */
  20481. static OCCLUSION_TYPE_STRICT: number;
  20482. /** Use an accurante occlusion algorithm */
  20483. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  20484. /** Use a conservative occlusion algorithm */
  20485. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  20486. /**
  20487. * No billboard
  20488. */
  20489. static readonly BILLBOARDMODE_NONE: number;
  20490. /** Billboard on X axis */
  20491. static readonly BILLBOARDMODE_X: number;
  20492. /** Billboard on Y axis */
  20493. static readonly BILLBOARDMODE_Y: number;
  20494. /** Billboard on Z axis */
  20495. static readonly BILLBOARDMODE_Z: number;
  20496. /** Billboard on all axes */
  20497. static readonly BILLBOARDMODE_ALL: number;
  20498. private _facetPositions;
  20499. private _facetNormals;
  20500. private _facetPartitioning;
  20501. private _facetNb;
  20502. private _partitioningSubdivisions;
  20503. private _partitioningBBoxRatio;
  20504. private _facetDataEnabled;
  20505. private _facetParameters;
  20506. private _bbSize;
  20507. private _subDiv;
  20508. private _facetDepthSort;
  20509. private _facetDepthSortEnabled;
  20510. private _depthSortedIndices;
  20511. private _depthSortedFacets;
  20512. private _facetDepthSortFunction;
  20513. private _facetDepthSortFrom;
  20514. private _facetDepthSortOrigin;
  20515. private _invertedMatrix;
  20516. /**
  20517. * Gets the number of facets in the mesh
  20518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  20519. */
  20520. readonly facetNb: number;
  20521. /**
  20522. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  20523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  20524. */
  20525. partitioningSubdivisions: number;
  20526. /**
  20527. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  20528. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  20529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  20530. */
  20531. partitioningBBoxRatio: number;
  20532. /**
  20533. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  20534. * Works only for updatable meshes.
  20535. * Doesn't work with multi-materials
  20536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  20537. */
  20538. mustDepthSortFacets: boolean;
  20539. /**
  20540. * The location (Vector3) where the facet depth sort must be computed from.
  20541. * By default, the active camera position.
  20542. * Used only when facet depth sort is enabled
  20543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  20544. */
  20545. facetDepthSortFrom: Vector3;
  20546. /**
  20547. * gets a boolean indicating if facetData is enabled
  20548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  20549. */
  20550. readonly isFacetDataEnabled: boolean;
  20551. /** @hidden */
  20552. _updateNonUniformScalingState(value: boolean): boolean;
  20553. /**
  20554. * An event triggered when this mesh collides with another one
  20555. */
  20556. onCollideObservable: Observable<AbstractMesh>;
  20557. private _onCollideObserver;
  20558. /** Set a function to call when this mesh collides with another one */
  20559. onCollide: () => void;
  20560. /**
  20561. * An event triggered when the collision's position changes
  20562. */
  20563. onCollisionPositionChangeObservable: Observable<Vector3>;
  20564. private _onCollisionPositionChangeObserver;
  20565. /** Set a function to call when the collision's position changes */
  20566. onCollisionPositionChange: () => void;
  20567. /**
  20568. * An event triggered when material is changed
  20569. */
  20570. onMaterialChangedObservable: Observable<AbstractMesh>;
  20571. /**
  20572. * Gets or sets the orientation for POV movement & rotation
  20573. */
  20574. definedFacingForward: boolean;
  20575. /**
  20576. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  20577. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  20578. * * 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.
  20579. * @see http://doc.babylonjs.com/features/occlusionquery
  20580. */
  20581. occlusionQueryAlgorithmType: number;
  20582. /**
  20583. * 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:
  20584. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  20585. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  20586. * * 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.
  20587. * @see http://doc.babylonjs.com/features/occlusionquery
  20588. */
  20589. occlusionType: number;
  20590. /**
  20591. * 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.
  20592. * The default value is -1 which means don't break the query and wait till the result
  20593. * @see http://doc.babylonjs.com/features/occlusionquery
  20594. */
  20595. occlusionRetryCount: number;
  20596. private _occlusionInternalRetryCounter;
  20597. protected _isOccluded: boolean;
  20598. /**
  20599. * 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
  20600. * @see http://doc.babylonjs.com/features/occlusionquery
  20601. */
  20602. isOccluded: boolean;
  20603. private _isOcclusionQueryInProgress;
  20604. /**
  20605. * Flag to check the progress status of the query
  20606. * @see http://doc.babylonjs.com/features/occlusionquery
  20607. */
  20608. readonly isOcclusionQueryInProgress: boolean;
  20609. private _occlusionQuery;
  20610. private _visibility;
  20611. /**
  20612. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  20613. */
  20614. /**
  20615. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  20616. */
  20617. visibility: number;
  20618. /** Gets or sets the alpha index used to sort transparent meshes
  20619. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  20620. */
  20621. alphaIndex: number;
  20622. /**
  20623. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  20624. */
  20625. isVisible: boolean;
  20626. /**
  20627. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  20628. */
  20629. isPickable: boolean;
  20630. /**
  20631. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  20632. */
  20633. showBoundingBox: boolean;
  20634. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  20635. showSubMeshesBoundingBox: boolean;
  20636. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  20637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  20638. */
  20639. isBlocker: boolean;
  20640. /**
  20641. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  20642. */
  20643. enablePointerMoveEvents: boolean;
  20644. /**
  20645. * Specifies the rendering group id for this mesh (0 by default)
  20646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  20647. */
  20648. renderingGroupId: number;
  20649. private _material;
  20650. /** Gets or sets current material */
  20651. material: Nullable<Material>;
  20652. private _receiveShadows;
  20653. /**
  20654. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  20655. * @see http://doc.babylonjs.com/babylon101/shadows
  20656. */
  20657. receiveShadows: boolean;
  20658. /**
  20659. * Gets or sets a boolean indicating if the outline must be rendered as well
  20660. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  20661. */
  20662. renderOutline: boolean;
  20663. /** Defines color to use when rendering outline */
  20664. outlineColor: Color3;
  20665. /** Define width to use when rendering outline */
  20666. outlineWidth: number;
  20667. /**
  20668. * Gets or sets a boolean indicating if the overlay must be rendered as well
  20669. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  20670. */
  20671. renderOverlay: boolean;
  20672. /** Defines color to use when rendering overlay */
  20673. overlayColor: Color3;
  20674. /** Defines alpha to use when rendering overlay */
  20675. overlayAlpha: number;
  20676. private _hasVertexAlpha;
  20677. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  20678. hasVertexAlpha: boolean;
  20679. private _useVertexColors;
  20680. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  20681. useVertexColors: boolean;
  20682. private _computeBonesUsingShaders;
  20683. /**
  20684. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  20685. */
  20686. computeBonesUsingShaders: boolean;
  20687. private _numBoneInfluencers;
  20688. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  20689. numBoneInfluencers: number;
  20690. private _applyFog;
  20691. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  20692. applyFog: boolean;
  20693. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  20694. useOctreeForRenderingSelection: boolean;
  20695. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  20696. useOctreeForPicking: boolean;
  20697. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  20698. useOctreeForCollisions: boolean;
  20699. private _layerMask;
  20700. /**
  20701. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  20702. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  20703. */
  20704. layerMask: number;
  20705. /**
  20706. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  20707. */
  20708. alwaysSelectAsActiveMesh: boolean;
  20709. /**
  20710. * Gets or sets the current action manager
  20711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20712. */
  20713. actionManager: Nullable<ActionManager>;
  20714. /**
  20715. * Gets or sets impostor used for physic simulation
  20716. * @see http://doc.babylonjs.com/features/physics_engine
  20717. */
  20718. physicsImpostor: Nullable<PhysicsImpostor>;
  20719. private _checkCollisions;
  20720. private _collisionMask;
  20721. private _collisionGroup;
  20722. /**
  20723. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  20724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20725. */
  20726. ellipsoid: Vector3;
  20727. /**
  20728. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  20729. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20730. */
  20731. ellipsoidOffset: Vector3;
  20732. private _collider;
  20733. private _oldPositionForCollisions;
  20734. private _diffPositionForCollisions;
  20735. /**
  20736. * Gets or sets a collision mask used to mask collisions (default is -1).
  20737. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  20738. */
  20739. collisionMask: number;
  20740. /**
  20741. * Gets or sets the current collision group mask (-1 by default).
  20742. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  20743. */
  20744. collisionGroup: number;
  20745. /**
  20746. * Defines edge width used when edgesRenderer is enabled
  20747. * @see https://www.babylonjs-playground.com/#10OJSG#13
  20748. */
  20749. edgesWidth: number;
  20750. /**
  20751. * Defines edge color used when edgesRenderer is enabled
  20752. * @see https://www.babylonjs-playground.com/#10OJSG#13
  20753. */
  20754. edgesColor: Color4;
  20755. /** @hidden */
  20756. _edgesRenderer: Nullable<EdgesRenderer>;
  20757. private _collisionsTransformMatrix;
  20758. private _collisionsScalingMatrix;
  20759. /** @hidden */
  20760. _masterMesh: Nullable<AbstractMesh>;
  20761. /** @hidden */
  20762. _boundingInfo: Nullable<BoundingInfo>;
  20763. /** @hidden */
  20764. _renderId: number;
  20765. /**
  20766. * Gets or sets the list of subMeshes
  20767. * @see http://doc.babylonjs.com/how_to/multi_materials
  20768. */
  20769. subMeshes: SubMesh[];
  20770. /** @hidden */
  20771. _submeshesOctree: Octree<SubMesh>;
  20772. /** @hidden */
  20773. _intersectionsInProgress: AbstractMesh[];
  20774. /** @hidden */
  20775. _unIndexed: boolean;
  20776. /** @hidden */
  20777. _lightSources: Light[];
  20778. /** @hidden */
  20779. readonly _positions: Nullable<Vector3[]>;
  20780. /** @hidden */
  20781. _waitingActions: any;
  20782. /** @hidden */
  20783. _waitingFreezeWorldMatrix: Nullable<boolean>;
  20784. private _skeleton;
  20785. /** @hidden */
  20786. _bonesTransformMatrices: Nullable<Float32Array>;
  20787. /**
  20788. * Gets or sets a skeleton to apply skining transformations
  20789. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  20790. */
  20791. skeleton: Nullable<Skeleton>;
  20792. /**
  20793. * Creates a new AbstractMesh
  20794. * @param name defines the name of the mesh
  20795. * @param scene defines the hosting scene
  20796. */
  20797. constructor(name: string, scene?: Nullable<Scene>);
  20798. /**
  20799. * Returns the string "AbstractMesh"
  20800. * @returns "AbstractMesh"
  20801. */
  20802. getClassName(): string;
  20803. /**
  20804. * Gets a string representation of the current mesh
  20805. * @param fullDetails defines a boolean indicating if full details must be included
  20806. * @returns a string representation of the current mesh
  20807. */
  20808. toString(fullDetails?: boolean): string;
  20809. /** @hidden */
  20810. _rebuild(): void;
  20811. /** @hidden */
  20812. _resyncLightSources(): void;
  20813. /** @hidden */
  20814. _resyncLighSource(light: Light): void;
  20815. /** @hidden */
  20816. _unBindEffect(): void;
  20817. /** @hidden */
  20818. _removeLightSource(light: Light): void;
  20819. private _markSubMeshesAsDirty(func);
  20820. /** @hidden */
  20821. _markSubMeshesAsLightDirty(): void;
  20822. /** @hidden */
  20823. _markSubMeshesAsAttributesDirty(): void;
  20824. /** @hidden */
  20825. _markSubMeshesAsMiscDirty(): void;
  20826. /**
  20827. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  20828. */
  20829. scaling: Vector3;
  20830. /**
  20831. * Disables the mesh edge rendering mode
  20832. * @returns the currentAbstractMesh
  20833. */
  20834. disableEdgesRendering(): AbstractMesh;
  20835. /**
  20836. * Enables the edge rendering mode on the mesh.
  20837. * This mode makes the mesh edges visible
  20838. * @param epsilon defines the maximal distance between two angles to detect a face
  20839. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20840. * @returns the currentAbstractMesh
  20841. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20842. */
  20843. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20844. /**
  20845. * Gets the edgesRenderer associated with the mesh
  20846. */
  20847. readonly edgesRenderer: Nullable<EdgesRenderer>;
  20848. /**
  20849. * Returns true if the mesh is blocked. Implemented by child classes
  20850. */
  20851. readonly isBlocked: boolean;
  20852. /**
  20853. * Returns the mesh itself by default. Implemented by child classes
  20854. * @param camera defines the camera to use to pick the right LOD level
  20855. * @returns the currentAbstractMesh
  20856. */
  20857. getLOD(camera: Camera): AbstractMesh;
  20858. /**
  20859. * Returns 0 by default. Implemented by child classes
  20860. * @returns an integer
  20861. */
  20862. getTotalVertices(): number;
  20863. /**
  20864. * Returns null by default. Implemented by child classes
  20865. * @returns null
  20866. */
  20867. getIndices(): Nullable<IndicesArray>;
  20868. /**
  20869. * Returns the array of the requested vertex data kind. Implemented by child classes
  20870. * @param kind defines the vertex data kind to use
  20871. * @returns null
  20872. */
  20873. getVerticesData(kind: string): Nullable<FloatArray>;
  20874. /**
  20875. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20876. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20877. * Note that a new underlying VertexBuffer object is created each call.
  20878. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20879. * @param kind defines vertex data kind:
  20880. * * BABYLON.VertexBuffer.PositionKind
  20881. * * BABYLON.VertexBuffer.UVKind
  20882. * * BABYLON.VertexBuffer.UV2Kind
  20883. * * BABYLON.VertexBuffer.UV3Kind
  20884. * * BABYLON.VertexBuffer.UV4Kind
  20885. * * BABYLON.VertexBuffer.UV5Kind
  20886. * * BABYLON.VertexBuffer.UV6Kind
  20887. * * BABYLON.VertexBuffer.ColorKind
  20888. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20889. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20890. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20891. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20892. * @param data defines the data source
  20893. * @param updatable defines if the data must be flagged as updatable (or static)
  20894. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  20895. * @returns the current mesh
  20896. */
  20897. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  20898. /**
  20899. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20900. * If the mesh has no geometry, it is simply returned as it is.
  20901. * @param kind defines vertex data kind:
  20902. * * BABYLON.VertexBuffer.PositionKind
  20903. * * BABYLON.VertexBuffer.UVKind
  20904. * * BABYLON.VertexBuffer.UV2Kind
  20905. * * BABYLON.VertexBuffer.UV3Kind
  20906. * * BABYLON.VertexBuffer.UV4Kind
  20907. * * BABYLON.VertexBuffer.UV5Kind
  20908. * * BABYLON.VertexBuffer.UV6Kind
  20909. * * BABYLON.VertexBuffer.ColorKind
  20910. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20911. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20912. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20913. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20914. * @param data defines the data source
  20915. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  20916. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  20917. * @returns the current mesh
  20918. */
  20919. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  20920. /**
  20921. * Sets the mesh indices,
  20922. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20923. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20924. * @param totalVertices Defines the total number of vertices
  20925. * @returns the current mesh
  20926. */
  20927. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  20928. /**
  20929. * Gets a boolean indicating if specific vertex data is present
  20930. * @param kind defines the vertex data kind to use
  20931. * @returns true is data kind is present
  20932. */
  20933. isVerticesDataPresent(kind: string): boolean;
  20934. /**
  20935. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  20936. * @returns a BoundingInfo
  20937. */
  20938. getBoundingInfo(): BoundingInfo;
  20939. /**
  20940. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  20941. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  20942. * @returns the current mesh
  20943. */
  20944. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  20945. /**
  20946. * Overwrite the current bounding info
  20947. * @param boundingInfo defines the new bounding info
  20948. * @returns the current mesh
  20949. */
  20950. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  20951. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  20952. readonly useBones: boolean;
  20953. /** @hidden */
  20954. _preActivate(): void;
  20955. /** @hidden */
  20956. _preActivateForIntermediateRendering(renderId: number): void;
  20957. /** @hidden */
  20958. _activate(renderId: number): void;
  20959. /**
  20960. * Gets the current world matrix
  20961. * @returns a Matrix
  20962. */
  20963. getWorldMatrix(): Matrix;
  20964. /** @hidden */
  20965. _getWorldMatrixDeterminant(): number;
  20966. /**
  20967. * Perform relative position change from the point of view of behind the front of the mesh.
  20968. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20969. * Supports definition of mesh facing forward or backward
  20970. * @param amountRight defines the distance on the right axis
  20971. * @param amountUp defines the distance on the up axis
  20972. * @param amountForward defines the distance on the forward axis
  20973. * @returns the current mesh
  20974. */
  20975. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  20976. /**
  20977. * Calculate relative position change from the point of view of behind the front of the mesh.
  20978. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20979. * Supports definition of mesh facing forward or backward
  20980. * @param amountRight defines the distance on the right axis
  20981. * @param amountUp defines the distance on the up axis
  20982. * @param amountForward defines the distance on the forward axis
  20983. * @returns the new displacement vector
  20984. */
  20985. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  20986. /**
  20987. * Perform relative rotation change from the point of view of behind the front of the mesh.
  20988. * Supports definition of mesh facing forward or backward
  20989. * @param flipBack defines the flip
  20990. * @param twirlClockwise defines the twirl
  20991. * @param tiltRight defines the tilt
  20992. * @returns the current mesh
  20993. */
  20994. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  20995. /**
  20996. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  20997. * Supports definition of mesh facing forward or backward.
  20998. * @param flipBack defines the flip
  20999. * @param twirlClockwise defines the twirl
  21000. * @param tiltRight defines the tilt
  21001. * @returns the new rotation vector
  21002. */
  21003. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  21004. /**
  21005. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  21006. * @param includeDescendants Include bounding info from descendants as well (true by default)
  21007. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  21008. * @returns the new bounding vectors
  21009. */
  21010. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  21011. min: Vector3;
  21012. max: Vector3;
  21013. };
  21014. /** @hidden */
  21015. _updateBoundingInfo(): AbstractMesh;
  21016. /** @hidden */
  21017. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  21018. /** @hidden */
  21019. protected _afterComputeWorldMatrix(): void;
  21020. /**
  21021. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21022. * A mesh is in the frustum if its bounding box intersects the frustum
  21023. * @param frustumPlanes defines the frustum to test
  21024. * @returns true if the mesh is in the frustum planes
  21025. */
  21026. isInFrustum(frustumPlanes: Plane[]): boolean;
  21027. /**
  21028. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  21029. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  21030. * @param frustumPlanes defines the frustum to test
  21031. * @returns true if the mesh is completely in the frustum planes
  21032. */
  21033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21034. /**
  21035. * True if the mesh intersects another mesh or a SolidParticle object
  21036. * @param mesh defines a target mesh or SolidParticle to test
  21037. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  21038. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  21039. * @returns true if there is an intersection
  21040. */
  21041. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  21042. /**
  21043. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  21044. * @param point defines the point to test
  21045. * @returns true if there is an intersection
  21046. */
  21047. intersectsPoint(point: Vector3): boolean;
  21048. /**
  21049. * Gets the current physics impostor
  21050. * @see http://doc.babylonjs.com/features/physics_engine
  21051. * @returns a physics impostor or null
  21052. */
  21053. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  21054. /**
  21055. * Gets the position of the current mesh in camera space
  21056. * @param camera defines the camera to use
  21057. * @returns a position
  21058. */
  21059. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  21060. /**
  21061. * Returns the distance from the mesh to the active camera
  21062. * @param camera defines the camera to use
  21063. * @returns the distance
  21064. */
  21065. getDistanceToCamera(camera?: Nullable<Camera>): number;
  21066. /**
  21067. * Apply a physic impulse to the mesh
  21068. * @param force defines the force to apply
  21069. * @param contactPoint defines where to apply the force
  21070. * @returns the current mesh
  21071. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  21072. */
  21073. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  21074. /**
  21075. * Creates a physic joint between two meshes
  21076. * @param otherMesh defines the other mesh to use
  21077. * @param pivot1 defines the pivot to use on this mesh
  21078. * @param pivot2 defines the pivot to use on the other mesh
  21079. * @param options defines additional options (can be plugin dependent)
  21080. * @returns the current mesh
  21081. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  21082. */
  21083. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  21084. /**
  21085. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  21086. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21087. */
  21088. checkCollisions: boolean;
  21089. /**
  21090. * Gets Collider object used to compute collisions (not physics)
  21091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21092. */
  21093. readonly collider: Collider;
  21094. /**
  21095. * Move the mesh using collision engine
  21096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  21097. * @param displacement defines the requested displacement vector
  21098. * @returns the current mesh
  21099. */
  21100. moveWithCollisions(displacement: Vector3): AbstractMesh;
  21101. private _onCollisionPositionChange;
  21102. /**
  21103. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  21104. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21105. * @param maxCapacity defines the maximum size of each block (64 by default)
  21106. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  21107. * @returns the new octree
  21108. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  21109. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  21110. */
  21111. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  21112. /** @hidden */
  21113. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  21114. /** @hidden */
  21115. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  21116. /** @hidden */
  21117. _checkCollision(collider: Collider): AbstractMesh;
  21118. /** @hidden */
  21119. _generatePointsArray(): boolean;
  21120. /**
  21121. * Checks if the passed Ray intersects with the mesh
  21122. * @param ray defines the ray to use
  21123. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  21124. * @returns the picking info
  21125. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  21126. */
  21127. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  21128. /**
  21129. * Clones the current mesh
  21130. * @param name defines the mesh name
  21131. * @param newParent defines the new mesh parent
  21132. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  21133. * @returns the new mesh
  21134. */
  21135. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  21136. /**
  21137. * Disposes all the submeshes of the current meshnp
  21138. * @returns the current mesh
  21139. */
  21140. releaseSubMeshes(): AbstractMesh;
  21141. /**
  21142. * Releases resources associated with this abstract mesh.
  21143. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21144. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21145. */
  21146. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21147. /**
  21148. * Adds the passed mesh as a child to the current mesh
  21149. * @param mesh defines the child mesh
  21150. * @returns the current mesh
  21151. */
  21152. addChild(mesh: AbstractMesh): AbstractMesh;
  21153. /**
  21154. * Removes the passed mesh from the current mesh children list
  21155. * @param mesh defines the child mesh
  21156. * @returns the current mesh
  21157. */
  21158. removeChild(mesh: AbstractMesh): AbstractMesh;
  21159. /** @hidden */
  21160. private _initFacetData();
  21161. /**
  21162. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  21163. * This method can be called within the render loop.
  21164. * 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
  21165. * @returns the current mesh
  21166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21167. */
  21168. updateFacetData(): AbstractMesh;
  21169. /**
  21170. * Returns the facetLocalNormals array.
  21171. * The normals are expressed in the mesh local spac
  21172. * @returns an array of Vector3
  21173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21174. */
  21175. getFacetLocalNormals(): Vector3[];
  21176. /**
  21177. * Returns the facetLocalPositions array.
  21178. * The facet positions are expressed in the mesh local space
  21179. * @returns an array of Vector3
  21180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21181. */
  21182. getFacetLocalPositions(): Vector3[];
  21183. /**
  21184. * Returns the facetLocalPartioning array
  21185. * @returns an array of array of numbers
  21186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21187. */
  21188. getFacetLocalPartitioning(): number[][];
  21189. /**
  21190. * Returns the i-th facet position in the world system.
  21191. * This method allocates a new Vector3 per call
  21192. * @param i defines the facet index
  21193. * @returns a new Vector3
  21194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21195. */
  21196. getFacetPosition(i: number): Vector3;
  21197. /**
  21198. * Sets the reference Vector3 with the i-th facet position in the world system
  21199. * @param i defines the facet index
  21200. * @param ref defines the target vector
  21201. * @returns the current mesh
  21202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21203. */
  21204. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  21205. /**
  21206. * Returns the i-th facet normal in the world system.
  21207. * This method allocates a new Vector3 per call
  21208. * @param i defines the facet index
  21209. * @returns a new Vector3
  21210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21211. */
  21212. getFacetNormal(i: number): Vector3;
  21213. /**
  21214. * Sets the reference Vector3 with the i-th facet normal in the world system
  21215. * @param i defines the facet index
  21216. * @param ref defines the target vector
  21217. * @returns the current mesh
  21218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21219. */
  21220. getFacetNormalToRef(i: number, ref: Vector3): this;
  21221. /**
  21222. * 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)
  21223. * @param x defines x coordinate
  21224. * @param y defines y coordinate
  21225. * @param z defines z coordinate
  21226. * @returns the array of facet indexes
  21227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21228. */
  21229. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  21230. /**
  21231. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  21232. * @param projected sets as the (x,y,z) world projection on the facet
  21233. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  21234. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  21235. * @param x defines x coordinate
  21236. * @param y defines y coordinate
  21237. * @param z defines z coordinate
  21238. * @returns the face index if found (or null instead)
  21239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21240. */
  21241. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  21242. /**
  21243. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  21244. * @param projected sets as the (x,y,z) local projection on the facet
  21245. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  21246. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  21247. * @param x defines x coordinate
  21248. * @param y defines y coordinate
  21249. * @param z defines z coordinate
  21250. * @returns the face index if found (or null instead)
  21251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21252. */
  21253. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  21254. /**
  21255. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  21256. * @returns the parameters
  21257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21258. */
  21259. getFacetDataParameters(): any;
  21260. /**
  21261. * Disables the feature FacetData and frees the related memory
  21262. * @returns the current mesh
  21263. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  21264. */
  21265. disableFacetData(): AbstractMesh;
  21266. /**
  21267. * Updates the AbstractMesh indices array
  21268. * @param indices defines the data source
  21269. * @returns the current mesh
  21270. */
  21271. updateIndices(indices: IndicesArray): AbstractMesh;
  21272. /**
  21273. * Creates new normals data for the mesh
  21274. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  21275. * @returns the current mesh
  21276. */
  21277. createNormals(updatable: boolean): AbstractMesh;
  21278. /**
  21279. * Align the mesh with a normal
  21280. * @param normal defines the normal to use
  21281. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  21282. * @returns the current mesh
  21283. */
  21284. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  21285. /** @hidden */
  21286. protected _checkOcclusionQuery(): void;
  21287. }
  21288. }
  21289. declare module BABYLON {
  21290. class Buffer {
  21291. private _engine;
  21292. private _buffer;
  21293. /** @hidden */
  21294. _data: Nullable<DataArray>;
  21295. private _updatable;
  21296. private _instanced;
  21297. /**
  21298. * Gets the byte stride.
  21299. */
  21300. readonly byteStride: number;
  21301. /**
  21302. * Constructor
  21303. * @param engine the engine
  21304. * @param data the data to use for this buffer
  21305. * @param updatable whether the data is updatable
  21306. * @param stride the stride (optional)
  21307. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  21308. * @param instanced whether the buffer is instanced (optional)
  21309. * @param useBytes set to true if the stride in in bytes (optional)
  21310. */
  21311. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  21312. /**
  21313. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  21314. * @param kind defines the vertex buffer kind (position, normal, etc.)
  21315. * @param offset defines offset in the buffer (0 by default)
  21316. * @param size defines the size in floats of attributes (position is 3 for instance)
  21317. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  21318. * @param instanced defines if the vertex buffer contains indexed data
  21319. * @param useBytes defines if the offset and stride are in bytes
  21320. * @returns the new vertex buffer
  21321. */
  21322. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  21323. isUpdatable(): boolean;
  21324. getData(): Nullable<DataArray>;
  21325. getBuffer(): Nullable<WebGLBuffer>;
  21326. /**
  21327. * Gets the stride in float32 units (i.e. byte stride / 4).
  21328. * May not be an integer if the byte stride is not divisible by 4.
  21329. * DEPRECATED. Use byteStride instead.
  21330. * @returns the stride in float32 units
  21331. */
  21332. getStrideSize(): number;
  21333. create(data?: Nullable<DataArray>): void;
  21334. _rebuild(): void;
  21335. update(data: DataArray): void;
  21336. /**
  21337. * Updates the data directly.
  21338. * @param data the new data
  21339. * @param offset the new offset
  21340. * @param vertexCount the vertex count (optional)
  21341. * @param useBytes set to true if the offset is in bytes
  21342. */
  21343. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  21344. dispose(): void;
  21345. }
  21346. }
  21347. declare module BABYLON {
  21348. class CSG {
  21349. private polygons;
  21350. matrix: Matrix;
  21351. position: Vector3;
  21352. rotation: Vector3;
  21353. rotationQuaternion: Nullable<Quaternion>;
  21354. scaling: Vector3;
  21355. static FromMesh(mesh: Mesh): CSG;
  21356. private static FromPolygons(polygons);
  21357. clone(): CSG;
  21358. union(csg: CSG): CSG;
  21359. unionInPlace(csg: CSG): void;
  21360. subtract(csg: CSG): CSG;
  21361. subtractInPlace(csg: CSG): void;
  21362. intersect(csg: CSG): CSG;
  21363. intersectInPlace(csg: CSG): void;
  21364. inverse(): CSG;
  21365. inverseInPlace(): void;
  21366. copyTransformAttributes(csg: CSG): CSG;
  21367. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  21368. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  21369. }
  21370. }
  21371. declare module BABYLON {
  21372. /**
  21373. * Class used to store geometry data (vertex buffers + index buffer)
  21374. */
  21375. class Geometry implements IGetSetVerticesData {
  21376. /**
  21377. * Gets or sets the unique ID of the geometry
  21378. */
  21379. id: string;
  21380. /**
  21381. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21382. */
  21383. delayLoadState: number;
  21384. /**
  21385. * Gets the file containing the data to load when running in delay load state
  21386. */
  21387. delayLoadingFile: Nullable<string>;
  21388. /**
  21389. * Callback called when the geometry is updated
  21390. */
  21391. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21392. private _scene;
  21393. private _engine;
  21394. private _meshes;
  21395. private _totalVertices;
  21396. /** @hidden */
  21397. _indices: IndicesArray;
  21398. /** @hidden */
  21399. _vertexBuffers: {
  21400. [key: string]: VertexBuffer;
  21401. };
  21402. private _isDisposed;
  21403. private _extend;
  21404. private _boundingBias;
  21405. /** @hidden */
  21406. _delayInfo: Array<string>;
  21407. private _indexBuffer;
  21408. private _indexBufferIsUpdatable;
  21409. /** @hidden */
  21410. _boundingInfo: Nullable<BoundingInfo>;
  21411. /** @hidden */
  21412. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21413. /** @hidden */
  21414. _softwareSkinningRenderId: number;
  21415. private _vertexArrayObjects;
  21416. private _updatable;
  21417. /** @hidden */
  21418. _positions: Nullable<Vector3[]>;
  21419. /**
  21420. * 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
  21421. */
  21422. /**
  21423. * 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
  21424. */
  21425. boundingBias: Vector2;
  21426. /**
  21427. * Static function used to attach a new empty geometry to a mesh
  21428. * @param mesh defines the mesh to attach the geometry to
  21429. * @returns the new {BABYLON.Geometry}
  21430. */
  21431. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21432. /**
  21433. * Creates a new geometry
  21434. * @param id defines the unique ID
  21435. * @param scene defines the hosting scene
  21436. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  21437. * @param updatable defines if geometry must be updatable (false by default)
  21438. * @param mesh defines the mesh that will be associated with the geometry
  21439. */
  21440. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21441. /**
  21442. * Gets the current extend of the geometry
  21443. */
  21444. readonly extend: {
  21445. minimum: Vector3;
  21446. maximum: Vector3;
  21447. };
  21448. /**
  21449. * Gets the hosting scene
  21450. * @returns the hosting {BABYLON.Scene}
  21451. */
  21452. getScene(): Scene;
  21453. /**
  21454. * Gets the hosting engine
  21455. * @returns the hosting {BABYLON.Engine}
  21456. */
  21457. getEngine(): Engine;
  21458. /**
  21459. * Defines if the geometry is ready to use
  21460. * @returns true if the geometry is ready to be used
  21461. */
  21462. isReady(): boolean;
  21463. /**
  21464. * Gets a value indicating that the geometry should not be serialized
  21465. */
  21466. readonly doNotSerialize: boolean;
  21467. /** @hidden */
  21468. _rebuild(): void;
  21469. /**
  21470. * Affects all gemetry data in one call
  21471. * @param vertexData defines the geometry data
  21472. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21473. */
  21474. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21475. /**
  21476. * Set specific vertex data
  21477. * @param kind defines the data kind (Position, normal, etc...)
  21478. * @param data defines the vertex data to use
  21479. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21480. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21481. */
  21482. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21483. /**
  21484. * Removes a specific vertex data
  21485. * @param kind defines the data kind (Position, normal, etc...)
  21486. */
  21487. removeVerticesData(kind: string): void;
  21488. /**
  21489. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21490. * @param buffer defines the vertex buffer to use
  21491. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21492. */
  21493. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21494. /**
  21495. * Update a specific vertex buffer
  21496. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21497. * It will do nothing if the buffer is not updatable
  21498. * @param kind defines the data kind (Position, normal, etc...)
  21499. * @param data defines the data to use
  21500. * @param offset defines the offset in the target buffer where to store the data
  21501. * @param useBytes set to true if the offset is in bytes
  21502. */
  21503. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21504. /**
  21505. * Update a specific vertex buffer
  21506. * This function will create a new buffer if the current one is not updatable
  21507. * @param kind defines the data kind (Position, normal, etc...)
  21508. * @param data defines the data to use
  21509. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21510. */
  21511. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21512. private _updateBoundingInfo(updateExtends, data);
  21513. /** @hidden */
  21514. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21515. /**
  21516. * Gets total number of vertices
  21517. * @returns the total number of vertices
  21518. */
  21519. getTotalVertices(): number;
  21520. /**
  21521. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21522. * @param kind defines the data kind (Position, normal, etc...)
  21523. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21524. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21525. * @returns a float array containing vertex data
  21526. */
  21527. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21528. /**
  21529. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21530. * @param kind defines the data kind (Position, normal, etc...)
  21531. * @returns true if the vertex buffer with the specified kind is updatable
  21532. */
  21533. isVertexBufferUpdatable(kind: string): boolean;
  21534. /**
  21535. * Gets a specific vertex buffer
  21536. * @param kind defines the data kind (Position, normal, etc...)
  21537. * @returns a {BABYLON.VertexBuffer}
  21538. */
  21539. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21540. /**
  21541. * Returns all vertex buffers
  21542. * @return an object holding all vertex buffers indexed by kind
  21543. */
  21544. getVertexBuffers(): Nullable<{
  21545. [key: string]: VertexBuffer;
  21546. }>;
  21547. /**
  21548. * Gets a boolean indicating if specific vertex buffer is present
  21549. * @param kind defines the data kind (Position, normal, etc...)
  21550. * @returns true if data is present
  21551. */
  21552. isVerticesDataPresent(kind: string): boolean;
  21553. /**
  21554. * Gets a list of all attached data kinds (Position, normal, etc...)
  21555. * @returns a list of string containing all kinds
  21556. */
  21557. getVerticesDataKinds(): string[];
  21558. /**
  21559. * Update index buffer
  21560. * @param indices defines the indices to store in the index buffer
  21561. * @param offset defines the offset in the target buffer where to store the data
  21562. */
  21563. updateIndices(indices: IndicesArray, offset?: number): void;
  21564. /**
  21565. * Creates a new index buffer
  21566. * @param indices defines the indices to store in the index buffer
  21567. * @param totalVertices defines the total number of vertices (could be null)
  21568. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21569. */
  21570. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21571. /**
  21572. * Return the total number of indices
  21573. * @returns the total number of indices
  21574. */
  21575. getTotalIndices(): number;
  21576. /**
  21577. * Gets the index buffer array
  21578. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21579. * @returns the index buffer array
  21580. */
  21581. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21582. /**
  21583. * Gets the index buffer
  21584. * @return the index buffer
  21585. */
  21586. getIndexBuffer(): Nullable<WebGLBuffer>;
  21587. /** @hidden */
  21588. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21589. /**
  21590. * Release the associated resources for a specific mesh
  21591. * @param mesh defines the source mesh
  21592. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21593. */
  21594. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21595. /**
  21596. * Apply current geometry to a given mesh
  21597. * @param mesh defines the mesh to apply geometry to
  21598. */
  21599. applyToMesh(mesh: Mesh): void;
  21600. private _updateExtend(data?);
  21601. private _applyToMesh(mesh);
  21602. private notifyUpdate(kind?);
  21603. /**
  21604. * Load the geometry if it was flagged as delay loaded
  21605. * @param scene defines the hosting scene
  21606. * @param onLoaded defines a callback called when the geometry is loaded
  21607. */
  21608. load(scene: Scene, onLoaded?: () => void): void;
  21609. private _queueLoad(scene, onLoaded?);
  21610. /**
  21611. * Invert the geometry to move from a right handed system to a left handed one.
  21612. */
  21613. toLeftHanded(): void;
  21614. /** @hidden */
  21615. _resetPointsArrayCache(): void;
  21616. /** @hidden */
  21617. _generatePointsArray(): boolean;
  21618. /**
  21619. * Gets a value indicating if the geometry is disposed
  21620. * @returns true if the geometry was disposed
  21621. */
  21622. isDisposed(): boolean;
  21623. private _disposeVertexArrayObjects();
  21624. /**
  21625. * Free all associated resources
  21626. */
  21627. dispose(): void;
  21628. /**
  21629. * Clone the current geometry into a new geometry
  21630. * @param id defines the unique ID of the new geometry
  21631. * @returns a new geometry object
  21632. */
  21633. copy(id: string): Geometry;
  21634. /**
  21635. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21636. * @return a JSON representation of the current geometry data (without the vertices data)
  21637. */
  21638. serialize(): any;
  21639. private toNumberArray(origin);
  21640. /**
  21641. * Serialize all vertices data into a JSON oject
  21642. * @returns a JSON representation of the current geometry data
  21643. */
  21644. serializeVerticeData(): any;
  21645. /**
  21646. * Extracts a clone of a mesh geometry
  21647. * @param mesh defines the source mesh
  21648. * @param id defines the unique ID of the new geometry object
  21649. * @returns the new geometry object
  21650. */
  21651. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21652. /**
  21653. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21654. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21655. * Be aware Math.random() could cause collisions, but:
  21656. * "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"
  21657. * @returns a string containing a new GUID
  21658. */
  21659. static RandomId(): string;
  21660. /** @hidden */
  21661. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21662. private static _CleanMatricesWeights(parsedGeometry, mesh);
  21663. /**
  21664. * Create a new geometry from persisted data (Using .babylon file format)
  21665. * @param parsedVertexData defines the persisted data
  21666. * @param scene defines the hosting scene
  21667. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21668. * @returns the new geometry object
  21669. */
  21670. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21671. }
  21672. /**
  21673. * Abstract class used to provide common services for all typed geometries
  21674. * @hidden
  21675. */
  21676. class _PrimitiveGeometry extends Geometry {
  21677. private _canBeRegenerated;
  21678. private _beingRegenerated;
  21679. /**
  21680. * Creates a new typed geometry
  21681. * @param id defines the unique ID of the geometry
  21682. * @param scene defines the hosting scene
  21683. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21684. * @param mesh defines the hosting mesh (can be null)
  21685. */
  21686. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21687. /**
  21688. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  21689. * @returns true if the geometry can be regenerated
  21690. */
  21691. canBeRegenerated(): boolean;
  21692. /**
  21693. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  21694. */
  21695. regenerate(): void;
  21696. /**
  21697. * Clone the geometry
  21698. * @param id defines the unique ID of the new geometry
  21699. * @returns the new geometry
  21700. */
  21701. asNewGeometry(id: string): Geometry;
  21702. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21703. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  21704. /** @hidden */
  21705. _regenerateVertexData(): VertexData;
  21706. copy(id: string): Geometry;
  21707. serialize(): any;
  21708. }
  21709. /**
  21710. * Creates a ribbon geometry
  21711. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  21712. */
  21713. class RibbonGeometry extends _PrimitiveGeometry {
  21714. /**
  21715. * Defines the array of paths to use
  21716. */
  21717. pathArray: Vector3[][];
  21718. /**
  21719. * Defines if the last and first points of each path in your pathArray must be joined
  21720. */
  21721. closeArray: boolean;
  21722. /**
  21723. * Defines if the last and first points of each path in your pathArray must be joined
  21724. */
  21725. closePath: boolean;
  21726. /**
  21727. * Defines the offset between points
  21728. */
  21729. offset: number;
  21730. /**
  21731. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21732. */
  21733. side: number;
  21734. /**
  21735. * Creates a ribbon geometry
  21736. * @param id defines the unique ID of the geometry
  21737. * @param scene defines the hosting scene
  21738. * @param pathArray defines the array of paths to use
  21739. * @param closeArray defines if the last path and the first path must be joined
  21740. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  21741. * @param offset defines the offset between points
  21742. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21743. * @param mesh defines the hosting mesh (can be null)
  21744. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21745. */
  21746. constructor(id: string, scene: Scene,
  21747. /**
  21748. * Defines the array of paths to use
  21749. */
  21750. pathArray: Vector3[][],
  21751. /**
  21752. * Defines if the last and first points of each path in your pathArray must be joined
  21753. */
  21754. closeArray: boolean,
  21755. /**
  21756. * Defines if the last and first points of each path in your pathArray must be joined
  21757. */
  21758. closePath: boolean,
  21759. /**
  21760. * Defines the offset between points
  21761. */
  21762. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  21763. /**
  21764. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21765. */
  21766. side?: number);
  21767. /** @hidden */
  21768. _regenerateVertexData(): VertexData;
  21769. copy(id: string): Geometry;
  21770. }
  21771. /**
  21772. * Creates a box geometry
  21773. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  21774. */
  21775. class BoxGeometry extends _PrimitiveGeometry {
  21776. /**
  21777. * Defines the zise of the box (width, height and depth are the same)
  21778. */
  21779. size: number;
  21780. /**
  21781. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21782. */
  21783. side: number;
  21784. /**
  21785. * Creates a box geometry
  21786. * @param id defines the unique ID of the geometry
  21787. * @param scene defines the hosting scene
  21788. * @param size defines the zise of the box (width, height and depth are the same)
  21789. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21790. * @param mesh defines the hosting mesh (can be null)
  21791. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21792. */
  21793. constructor(id: string, scene: Scene,
  21794. /**
  21795. * Defines the zise of the box (width, height and depth are the same)
  21796. */
  21797. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21798. /**
  21799. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21800. */
  21801. side?: number);
  21802. _regenerateVertexData(): VertexData;
  21803. copy(id: string): Geometry;
  21804. serialize(): any;
  21805. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  21806. }
  21807. /**
  21808. * Creates a sphere geometry
  21809. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  21810. */
  21811. class SphereGeometry extends _PrimitiveGeometry {
  21812. /**
  21813. * Defines the number of segments to use to create the sphere
  21814. */
  21815. segments: number;
  21816. /**
  21817. * Defines the diameter of the sphere
  21818. */
  21819. diameter: number;
  21820. /**
  21821. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21822. */
  21823. side: number;
  21824. /**
  21825. * Create a new sphere geometry
  21826. * @param id defines the unique ID of the geometry
  21827. * @param scene defines the hosting scene
  21828. * @param segments defines the number of segments to use to create the sphere
  21829. * @param diameter defines the diameter of the sphere
  21830. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21831. * @param mesh defines the hosting mesh (can be null)
  21832. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21833. */
  21834. constructor(id: string, scene: Scene,
  21835. /**
  21836. * Defines the number of segments to use to create the sphere
  21837. */
  21838. segments: number,
  21839. /**
  21840. * Defines the diameter of the sphere
  21841. */
  21842. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21843. /**
  21844. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21845. */
  21846. side?: number);
  21847. _regenerateVertexData(): VertexData;
  21848. copy(id: string): Geometry;
  21849. serialize(): any;
  21850. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  21851. }
  21852. /**
  21853. * Creates a disc geometry
  21854. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21855. */
  21856. class DiscGeometry extends _PrimitiveGeometry {
  21857. /**
  21858. * Defines the radius of the disc
  21859. */
  21860. radius: number;
  21861. /**
  21862. * Defines the tesselation factor to apply to the disc
  21863. */
  21864. tessellation: number;
  21865. /**
  21866. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21867. */
  21868. side: number;
  21869. /**
  21870. * Creates a new disc geometry
  21871. * @param id defines the unique ID of the geometry
  21872. * @param scene defines the hosting scene
  21873. * @param radius defines the radius of the disc
  21874. * @param tessellation defines the tesselation factor to apply to the disc
  21875. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21876. * @param mesh defines the hosting mesh (can be null)
  21877. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21878. */
  21879. constructor(id: string, scene: Scene,
  21880. /**
  21881. * Defines the radius of the disc
  21882. */
  21883. radius: number,
  21884. /**
  21885. * Defines the tesselation factor to apply to the disc
  21886. */
  21887. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21888. /**
  21889. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21890. */
  21891. side?: number);
  21892. _regenerateVertexData(): VertexData;
  21893. copy(id: string): Geometry;
  21894. }
  21895. /**
  21896. * Creates a new cylinder geometry
  21897. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  21898. */
  21899. class CylinderGeometry extends _PrimitiveGeometry {
  21900. /**
  21901. * Defines the height of the cylinder
  21902. */
  21903. height: number;
  21904. /**
  21905. * Defines the diameter of the cylinder's top cap
  21906. */
  21907. diameterTop: number;
  21908. /**
  21909. * Defines the diameter of the cylinder's bottom cap
  21910. */
  21911. diameterBottom: number;
  21912. /**
  21913. * Defines the tessellation factor to apply to the cylinder
  21914. */
  21915. tessellation: number;
  21916. /**
  21917. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21918. */
  21919. subdivisions: number;
  21920. /**
  21921. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21922. */
  21923. side: number;
  21924. /**
  21925. * Creates a new cylinder geometry
  21926. * @param id defines the unique ID of the geometry
  21927. * @param scene defines the hosting scene
  21928. * @param height defines the height of the cylinder
  21929. * @param diameterTop defines the diameter of the cylinder's top cap
  21930. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  21931. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  21932. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  21933. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21934. * @param mesh defines the hosting mesh (can be null)
  21935. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21936. */
  21937. constructor(id: string, scene: Scene,
  21938. /**
  21939. * Defines the height of the cylinder
  21940. */
  21941. height: number,
  21942. /**
  21943. * Defines the diameter of the cylinder's top cap
  21944. */
  21945. diameterTop: number,
  21946. /**
  21947. * Defines the diameter of the cylinder's bottom cap
  21948. */
  21949. diameterBottom: number,
  21950. /**
  21951. * Defines the tessellation factor to apply to the cylinder
  21952. */
  21953. tessellation: number,
  21954. /**
  21955. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21956. */
  21957. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21958. /**
  21959. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21960. */
  21961. side?: number);
  21962. _regenerateVertexData(): VertexData;
  21963. copy(id: string): Geometry;
  21964. serialize(): any;
  21965. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  21966. }
  21967. /**
  21968. * Creates a new torus geometry
  21969. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  21970. */
  21971. class TorusGeometry extends _PrimitiveGeometry {
  21972. /**
  21973. * Defines the diameter of the torus
  21974. */
  21975. diameter: number;
  21976. /**
  21977. * Defines the thickness of the torus (ie. internal diameter)
  21978. */
  21979. thickness: number;
  21980. /**
  21981. * Defines the tesselation factor to apply to the torus
  21982. */
  21983. tessellation: number;
  21984. /**
  21985. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21986. */
  21987. side: number;
  21988. /**
  21989. * Creates a new torus geometry
  21990. * @param id defines the unique ID of the geometry
  21991. * @param scene defines the hosting scene
  21992. * @param diameter defines the diameter of the torus
  21993. * @param thickness defines the thickness of the torus (ie. internal diameter)
  21994. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  21995. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21996. * @param mesh defines the hosting mesh (can be null)
  21997. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21998. */
  21999. constructor(id: string, scene: Scene,
  22000. /**
  22001. * Defines the diameter of the torus
  22002. */
  22003. diameter: number,
  22004. /**
  22005. * Defines the thickness of the torus (ie. internal diameter)
  22006. */
  22007. thickness: number,
  22008. /**
  22009. * Defines the tesselation factor to apply to the torus
  22010. */
  22011. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22012. /**
  22013. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22014. */
  22015. side?: number);
  22016. _regenerateVertexData(): VertexData;
  22017. copy(id: string): Geometry;
  22018. serialize(): any;
  22019. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  22020. }
  22021. /**
  22022. * Creates a new ground geometry
  22023. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  22024. */
  22025. class GroundGeometry extends _PrimitiveGeometry {
  22026. /**
  22027. * Defines the width of the ground
  22028. */
  22029. width: number;
  22030. /**
  22031. * Defines the height of the ground
  22032. */
  22033. height: number;
  22034. /**
  22035. * Defines the subdivisions to apply to the ground
  22036. */
  22037. subdivisions: number;
  22038. /**
  22039. * Creates a new ground geometry
  22040. * @param id defines the unique ID of the geometry
  22041. * @param scene defines the hosting scene
  22042. * @param width defines the width of the ground
  22043. * @param height defines the height of the ground
  22044. * @param subdivisions defines the subdivisions to apply to the ground
  22045. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22046. * @param mesh defines the hosting mesh (can be null)
  22047. */
  22048. constructor(id: string, scene: Scene,
  22049. /**
  22050. * Defines the width of the ground
  22051. */
  22052. width: number,
  22053. /**
  22054. * Defines the height of the ground
  22055. */
  22056. height: number,
  22057. /**
  22058. * Defines the subdivisions to apply to the ground
  22059. */
  22060. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22061. _regenerateVertexData(): VertexData;
  22062. copy(id: string): Geometry;
  22063. serialize(): any;
  22064. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  22065. }
  22066. /**
  22067. * Creates a tiled ground geometry
  22068. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  22069. */
  22070. class TiledGroundGeometry extends _PrimitiveGeometry {
  22071. /**
  22072. * Defines the minimum value on X axis
  22073. */
  22074. xmin: number;
  22075. /**
  22076. * Defines the minimum value on Z axis
  22077. */
  22078. zmin: number;
  22079. /**
  22080. * Defines the maximum value on X axis
  22081. */
  22082. xmax: number;
  22083. /**
  22084. * Defines the maximum value on Z axis
  22085. */
  22086. zmax: number;
  22087. /**
  22088. * Defines the subdivisions to apply to the ground
  22089. */
  22090. subdivisions: {
  22091. w: number;
  22092. h: number;
  22093. };
  22094. /**
  22095. * Defines the precision to use when computing the tiles
  22096. */
  22097. precision: {
  22098. w: number;
  22099. h: number;
  22100. };
  22101. /**
  22102. * Creates a tiled ground geometry
  22103. * @param id defines the unique ID of the geometry
  22104. * @param scene defines the hosting scene
  22105. * @param xmin defines the minimum value on X axis
  22106. * @param zmin defines the minimum value on Z axis
  22107. * @param xmax defines the maximum value on X axis
  22108. * @param zmax defines the maximum value on Z axis
  22109. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  22110. * @param precision defines the precision to use when computing the tiles
  22111. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22112. * @param mesh defines the hosting mesh (can be null)
  22113. */
  22114. constructor(id: string, scene: Scene,
  22115. /**
  22116. * Defines the minimum value on X axis
  22117. */
  22118. xmin: number,
  22119. /**
  22120. * Defines the minimum value on Z axis
  22121. */
  22122. zmin: number,
  22123. /**
  22124. * Defines the maximum value on X axis
  22125. */
  22126. xmax: number,
  22127. /**
  22128. * Defines the maximum value on Z axis
  22129. */
  22130. zmax: number,
  22131. /**
  22132. * Defines the subdivisions to apply to the ground
  22133. */
  22134. subdivisions: {
  22135. w: number;
  22136. h: number;
  22137. },
  22138. /**
  22139. * Defines the precision to use when computing the tiles
  22140. */
  22141. precision: {
  22142. w: number;
  22143. h: number;
  22144. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22145. _regenerateVertexData(): VertexData;
  22146. copy(id: string): Geometry;
  22147. }
  22148. /**
  22149. * Creates a plane geometry
  22150. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  22151. */
  22152. class PlaneGeometry extends _PrimitiveGeometry {
  22153. /**
  22154. * Defines the size of the plane (width === height)
  22155. */
  22156. size: number;
  22157. /**
  22158. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22159. */
  22160. side: number;
  22161. /**
  22162. * Creates a plane geometry
  22163. * @param id defines the unique ID of the geometry
  22164. * @param scene defines the hosting scene
  22165. * @param size defines the size of the plane (width === height)
  22166. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22167. * @param mesh defines the hosting mesh (can be null)
  22168. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22169. */
  22170. constructor(id: string, scene: Scene,
  22171. /**
  22172. * Defines the size of the plane (width === height)
  22173. */
  22174. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22175. /**
  22176. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22177. */
  22178. side?: number);
  22179. _regenerateVertexData(): VertexData;
  22180. copy(id: string): Geometry;
  22181. serialize(): any;
  22182. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  22183. }
  22184. /**
  22185. * Creates a torus knot geometry
  22186. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  22187. */
  22188. class TorusKnotGeometry extends _PrimitiveGeometry {
  22189. /**
  22190. * Defines the radius of the torus knot
  22191. */
  22192. radius: number;
  22193. /**
  22194. * Defines the thickness of the torus knot tube
  22195. */
  22196. tube: number;
  22197. /**
  22198. * Defines the number of radial segments
  22199. */
  22200. radialSegments: number;
  22201. /**
  22202. * Defines the number of tubular segments
  22203. */
  22204. tubularSegments: number;
  22205. /**
  22206. * Defines the first number of windings
  22207. */
  22208. p: number;
  22209. /**
  22210. * Defines the second number of windings
  22211. */
  22212. q: number;
  22213. /**
  22214. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22215. */
  22216. side: number;
  22217. /**
  22218. * Creates a torus knot geometry
  22219. * @param id defines the unique ID of the geometry
  22220. * @param scene defines the hosting scene
  22221. * @param radius defines the radius of the torus knot
  22222. * @param tube defines the thickness of the torus knot tube
  22223. * @param radialSegments defines the number of radial segments
  22224. * @param tubularSegments defines the number of tubular segments
  22225. * @param p defines the first number of windings
  22226. * @param q defines the second number of windings
  22227. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22228. * @param mesh defines the hosting mesh (can be null)
  22229. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22230. */
  22231. constructor(id: string, scene: Scene,
  22232. /**
  22233. * Defines the radius of the torus knot
  22234. */
  22235. radius: number,
  22236. /**
  22237. * Defines the thickness of the torus knot tube
  22238. */
  22239. tube: number,
  22240. /**
  22241. * Defines the number of radial segments
  22242. */
  22243. radialSegments: number,
  22244. /**
  22245. * Defines the number of tubular segments
  22246. */
  22247. tubularSegments: number,
  22248. /**
  22249. * Defines the first number of windings
  22250. */
  22251. p: number,
  22252. /**
  22253. * Defines the second number of windings
  22254. */
  22255. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22256. /**
  22257. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  22258. */
  22259. side?: number);
  22260. _regenerateVertexData(): VertexData;
  22261. copy(id: string): Geometry;
  22262. serialize(): any;
  22263. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  22264. }
  22265. }
  22266. declare module BABYLON {
  22267. class GroundMesh extends Mesh {
  22268. generateOctree: boolean;
  22269. private _heightQuads;
  22270. _subdivisionsX: number;
  22271. _subdivisionsY: number;
  22272. _width: number;
  22273. _height: number;
  22274. _minX: number;
  22275. _maxX: number;
  22276. _minZ: number;
  22277. _maxZ: number;
  22278. constructor(name: string, scene: Scene);
  22279. getClassName(): string;
  22280. readonly subdivisions: number;
  22281. readonly subdivisionsX: number;
  22282. readonly subdivisionsY: number;
  22283. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22284. /**
  22285. * Returns a height (y) value in the Worl system :
  22286. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22287. * Returns the ground y position if (x, z) are outside the ground surface.
  22288. */
  22289. getHeightAtCoordinates(x: number, z: number): number;
  22290. /**
  22291. * Returns a normalized vector (Vector3) orthogonal to the ground
  22292. * at the ground coordinates (x, z) expressed in the World system.
  22293. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22294. */
  22295. getNormalAtCoordinates(x: number, z: number): Vector3;
  22296. /**
  22297. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22298. * at the ground coordinates (x, z) expressed in the World system.
  22299. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22300. * Returns the GroundMesh.
  22301. */
  22302. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22303. /**
  22304. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22305. * if the ground has been updated.
  22306. * This can be used in the render loop.
  22307. * Returns the GroundMesh.
  22308. */
  22309. updateCoordinateHeights(): GroundMesh;
  22310. private _getFacetAt(x, z);
  22311. private _initHeightQuads();
  22312. private _computeHeightQuads();
  22313. serialize(serializationObject: any): void;
  22314. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22315. }
  22316. }
  22317. declare module BABYLON {
  22318. /**
  22319. * Creates an instance based on a source mesh.
  22320. */
  22321. class InstancedMesh extends AbstractMesh {
  22322. private _sourceMesh;
  22323. private _currentLOD;
  22324. constructor(name: string, source: Mesh);
  22325. /**
  22326. * Returns the string "InstancedMesh".
  22327. */
  22328. getClassName(): string;
  22329. readonly receiveShadows: boolean;
  22330. readonly material: Nullable<Material>;
  22331. readonly visibility: number;
  22332. readonly skeleton: Nullable<Skeleton>;
  22333. renderingGroupId: number;
  22334. /**
  22335. * Returns the total number of vertices (integer).
  22336. */
  22337. getTotalVertices(): number;
  22338. readonly sourceMesh: Mesh;
  22339. /**
  22340. * Is this node ready to be used/rendered
  22341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  22342. * @return {boolean} is it ready
  22343. */
  22344. isReady(completeCheck?: boolean): boolean;
  22345. /**
  22346. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  22347. */
  22348. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  22349. /**
  22350. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22351. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22352. * The `data` are either a numeric array either a Float32Array.
  22353. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  22354. * 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).
  22355. * Note that a new underlying VertexBuffer object is created each call.
  22356. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22357. *
  22358. * Possible `kind` values :
  22359. * - BABYLON.VertexBuffer.PositionKind
  22360. * - BABYLON.VertexBuffer.UVKind
  22361. * - BABYLON.VertexBuffer.UV2Kind
  22362. * - BABYLON.VertexBuffer.UV3Kind
  22363. * - BABYLON.VertexBuffer.UV4Kind
  22364. * - BABYLON.VertexBuffer.UV5Kind
  22365. * - BABYLON.VertexBuffer.UV6Kind
  22366. * - BABYLON.VertexBuffer.ColorKind
  22367. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22368. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22369. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22370. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22371. *
  22372. * Returns the Mesh.
  22373. */
  22374. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  22375. /**
  22376. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22377. * If the mesh has no geometry, it is simply returned as it is.
  22378. * The `data` are either a numeric array either a Float32Array.
  22379. * No new underlying VertexBuffer object is created.
  22380. * 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.
  22381. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  22382. *
  22383. * Possible `kind` values :
  22384. * - BABYLON.VertexBuffer.PositionKind
  22385. * - BABYLON.VertexBuffer.UVKind
  22386. * - BABYLON.VertexBuffer.UV2Kind
  22387. * - BABYLON.VertexBuffer.UV3Kind
  22388. * - BABYLON.VertexBuffer.UV4Kind
  22389. * - BABYLON.VertexBuffer.UV5Kind
  22390. * - BABYLON.VertexBuffer.UV6Kind
  22391. * - BABYLON.VertexBuffer.ColorKind
  22392. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22393. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22394. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22395. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22396. *
  22397. * Returns the Mesh.
  22398. */
  22399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  22400. /**
  22401. * Sets the mesh indices.
  22402. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  22403. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22404. * This method creates a new index buffer each call.
  22405. * Returns the Mesh.
  22406. */
  22407. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  22408. /**
  22409. * Boolean : True if the mesh owns the requested kind of data.
  22410. */
  22411. isVerticesDataPresent(kind: string): boolean;
  22412. /**
  22413. * Returns an array of indices (IndicesArray).
  22414. */
  22415. getIndices(): Nullable<IndicesArray>;
  22416. readonly _positions: Nullable<Vector3[]>;
  22417. /**
  22418. * Sets a new updated BoundingInfo to the mesh.
  22419. * Returns the mesh.
  22420. */
  22421. refreshBoundingInfo(): InstancedMesh;
  22422. _preActivate(): InstancedMesh;
  22423. _activate(renderId: number): InstancedMesh;
  22424. /**
  22425. * Returns the current associated LOD AbstractMesh.
  22426. */
  22427. getLOD(camera: Camera): AbstractMesh;
  22428. _syncSubMeshes(): InstancedMesh;
  22429. _generatePointsArray(): boolean;
  22430. /**
  22431. * Creates a new InstancedMesh from the current mesh.
  22432. * - name (string) : the cloned mesh name
  22433. * - newParent (optional Node) : the optional Node to parent the clone to.
  22434. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  22435. *
  22436. * Returns the clone.
  22437. */
  22438. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  22439. /**
  22440. * Disposes the InstancedMesh.
  22441. * Returns nothing.
  22442. */
  22443. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22444. }
  22445. }
  22446. declare module BABYLON {
  22447. class LinesMesh extends Mesh {
  22448. useVertexColor: boolean | undefined;
  22449. useVertexAlpha: boolean | undefined;
  22450. color: Color3;
  22451. alpha: number;
  22452. /**
  22453. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  22454. * This margin is expressed in world space coordinates, so its value may vary.
  22455. * Default value is 0.1
  22456. * @returns the intersection Threshold value.
  22457. */
  22458. /**
  22459. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  22460. * This margin is expressed in world space coordinates, so its value may vary.
  22461. * @param value the new threshold to apply
  22462. */
  22463. intersectionThreshold: number;
  22464. private _intersectionThreshold;
  22465. private _colorShader;
  22466. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  22467. /**
  22468. * Returns the string "LineMesh"
  22469. */
  22470. getClassName(): string;
  22471. material: Material;
  22472. readonly checkCollisions: boolean;
  22473. createInstance(name: string): InstancedMesh;
  22474. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  22475. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  22476. dispose(doNotRecurse?: boolean): void;
  22477. /**
  22478. * Returns a new LineMesh object cloned from the current one.
  22479. */
  22480. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  22481. }
  22482. }
  22483. declare module BABYLON {
  22484. /**
  22485. * @hidden
  22486. **/
  22487. class _InstancesBatch {
  22488. mustReturn: boolean;
  22489. visibleInstances: Nullable<InstancedMesh[]>[];
  22490. renderSelf: boolean[];
  22491. }
  22492. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  22493. static _FRONTSIDE: number;
  22494. static _BACKSIDE: number;
  22495. static _DOUBLESIDE: number;
  22496. static _DEFAULTSIDE: number;
  22497. static _NO_CAP: number;
  22498. static _CAP_START: number;
  22499. static _CAP_END: number;
  22500. static _CAP_ALL: number;
  22501. /**
  22502. * Mesh side orientation : usually the external or front surface
  22503. */
  22504. static readonly FRONTSIDE: number;
  22505. /**
  22506. * Mesh side orientation : usually the internal or back surface
  22507. */
  22508. static readonly BACKSIDE: number;
  22509. /**
  22510. * Mesh side orientation : both internal and external or front and back surfaces
  22511. */
  22512. static readonly DOUBLESIDE: number;
  22513. /**
  22514. * Mesh side orientation : by default, `FRONTSIDE`
  22515. */
  22516. static readonly DEFAULTSIDE: number;
  22517. /**
  22518. * Mesh cap setting : no cap
  22519. */
  22520. static readonly NO_CAP: number;
  22521. /**
  22522. * Mesh cap setting : one cap at the beginning of the mesh
  22523. */
  22524. static readonly CAP_START: number;
  22525. /**
  22526. * Mesh cap setting : one cap at the end of the mesh
  22527. */
  22528. static readonly CAP_END: number;
  22529. /**
  22530. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  22531. */
  22532. static readonly CAP_ALL: number;
  22533. /**
  22534. * An event triggered before rendering the mesh
  22535. */
  22536. onBeforeRenderObservable: Observable<Mesh>;
  22537. /**
  22538. * An event triggered after rendering the mesh
  22539. */
  22540. onAfterRenderObservable: Observable<Mesh>;
  22541. /**
  22542. * An event triggered before drawing the mesh
  22543. */
  22544. onBeforeDrawObservable: Observable<Mesh>;
  22545. private _onBeforeDrawObserver;
  22546. onBeforeDraw: () => void;
  22547. delayLoadState: number;
  22548. instances: InstancedMesh[];
  22549. delayLoadingFile: string;
  22550. _binaryInfo: any;
  22551. private _LODLevels;
  22552. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  22553. private _morphTargetManager;
  22554. morphTargetManager: Nullable<MorphTargetManager>;
  22555. _geometry: Nullable<Geometry>;
  22556. _delayInfo: Array<string>;
  22557. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  22558. _visibleInstances: any;
  22559. private _renderIdForInstances;
  22560. private _batchCache;
  22561. private _instancesBufferSize;
  22562. private _instancesBuffer;
  22563. private _instancesData;
  22564. private _overridenInstanceCount;
  22565. private _effectiveMaterial;
  22566. _shouldGenerateFlatShading: boolean;
  22567. private _preActivateId;
  22568. _originalBuilderSideOrientation: number;
  22569. overrideMaterialSideOrientation: Nullable<number>;
  22570. private _areNormalsFrozen;
  22571. private _sourcePositions;
  22572. private _sourceNormals;
  22573. private _source;
  22574. readonly source: Nullable<Mesh>;
  22575. isUnIndexed: boolean;
  22576. /**
  22577. * @constructor
  22578. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  22579. * @param {Scene} scene The scene to add this mesh to.
  22580. * @param {Node} parent The parent of this mesh, if it has one
  22581. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  22582. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  22583. * When false, achieved by calling a clone(), also passing False.
  22584. * This will make creation of children, recursive.
  22585. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  22586. */
  22587. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  22588. /**
  22589. * Returns the string "Mesh".
  22590. */
  22591. getClassName(): string;
  22592. /**
  22593. * Returns a string.
  22594. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  22595. */
  22596. toString(fullDetails?: boolean): string;
  22597. _unBindEffect(): void;
  22598. /**
  22599. * True if the mesh has some Levels Of Details (LOD).
  22600. * Returns a boolean.
  22601. */
  22602. readonly hasLODLevels: boolean;
  22603. /**
  22604. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  22605. * @returns an array of {BABYLON.MeshLODLevel}
  22606. */
  22607. getLODLevels(): MeshLODLevel[];
  22608. private _sortLODLevels();
  22609. /**
  22610. * Add a mesh as LOD level triggered at the given distance.
  22611. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22612. * @param {number} distance The distance from the center of the object to show this level
  22613. * @param {Mesh} mesh The mesh to be added as LOD level
  22614. * @return {Mesh} This mesh (for chaining)
  22615. */
  22616. addLODLevel(distance: number, mesh: Mesh): Mesh;
  22617. /**
  22618. * Returns the LOD level mesh at the passed distance or null if not found.
  22619. * It is related to the method `addLODLevel(distance, mesh)`.
  22620. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22621. * Returns an object Mesh or `null`.
  22622. */
  22623. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  22624. /**
  22625. * Remove a mesh from the LOD array
  22626. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22627. * @param {Mesh} mesh The mesh to be removed.
  22628. * @return {Mesh} This mesh (for chaining)
  22629. */
  22630. removeLODLevel(mesh: Mesh): Mesh;
  22631. /**
  22632. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  22633. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22634. */
  22635. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  22636. /**
  22637. * Returns the mesh internal Geometry object.
  22638. */
  22639. readonly geometry: Nullable<Geometry>;
  22640. /**
  22641. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  22642. */
  22643. getTotalVertices(): number;
  22644. /**
  22645. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  22646. * 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.
  22647. * You can force the copy with forceCopy === true
  22648. * Returns null if the mesh has no geometry or no vertex buffer.
  22649. * Possible `kind` values :
  22650. * - BABYLON.VertexBuffer.PositionKind
  22651. * - BABYLON.VertexBuffer.UVKind
  22652. * - BABYLON.VertexBuffer.UV2Kind
  22653. * - BABYLON.VertexBuffer.UV3Kind
  22654. * - BABYLON.VertexBuffer.UV4Kind
  22655. * - BABYLON.VertexBuffer.UV5Kind
  22656. * - BABYLON.VertexBuffer.UV6Kind
  22657. * - BABYLON.VertexBuffer.ColorKind
  22658. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22659. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22660. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22661. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22662. */
  22663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22664. /**
  22665. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  22666. * Returns `null` if the mesh has no geometry.
  22667. * Possible `kind` values :
  22668. * - BABYLON.VertexBuffer.PositionKind
  22669. * - BABYLON.VertexBuffer.UVKind
  22670. * - BABYLON.VertexBuffer.UV2Kind
  22671. * - BABYLON.VertexBuffer.UV3Kind
  22672. * - BABYLON.VertexBuffer.UV4Kind
  22673. * - BABYLON.VertexBuffer.UV5Kind
  22674. * - BABYLON.VertexBuffer.UV6Kind
  22675. * - BABYLON.VertexBuffer.ColorKind
  22676. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22677. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22678. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22679. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22680. */
  22681. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22682. isVerticesDataPresent(kind: string): boolean;
  22683. /**
  22684. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  22685. * Possible `kind` values :
  22686. * - BABYLON.VertexBuffer.PositionKind
  22687. * - BABYLON.VertexBuffer.UVKind
  22688. * - BABYLON.VertexBuffer.UV2Kind
  22689. * - BABYLON.VertexBuffer.UV3Kind
  22690. * - BABYLON.VertexBuffer.UV4Kind
  22691. * - BABYLON.VertexBuffer.UV5Kind
  22692. * - BABYLON.VertexBuffer.UV6Kind
  22693. * - BABYLON.VertexBuffer.ColorKind
  22694. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22695. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22696. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22697. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22698. */
  22699. isVertexBufferUpdatable(kind: string): boolean;
  22700. /**
  22701. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  22702. * Possible `kind` values :
  22703. * - BABYLON.VertexBuffer.PositionKind
  22704. * - BABYLON.VertexBuffer.UVKind
  22705. * - BABYLON.VertexBuffer.UV2Kind
  22706. * - BABYLON.VertexBuffer.UV3Kind
  22707. * - BABYLON.VertexBuffer.UV4Kind
  22708. * - BABYLON.VertexBuffer.UV5Kind
  22709. * - BABYLON.VertexBuffer.UV6Kind
  22710. * - BABYLON.VertexBuffer.ColorKind
  22711. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22712. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22713. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22714. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22715. */
  22716. getVerticesDataKinds(): string[];
  22717. /**
  22718. * Returns a positive integer : the total number of indices in this mesh geometry.
  22719. * Returns zero if the mesh has no geometry.
  22720. */
  22721. getTotalIndices(): number;
  22722. /**
  22723. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22724. * 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.
  22725. * Returns an empty array if the mesh has no geometry.
  22726. */
  22727. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22728. readonly isBlocked: boolean;
  22729. /**
  22730. * Determine if the current mesh is ready to be rendered
  22731. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  22732. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  22733. * @returns true if all associated assets are ready (material, textures, shaders)
  22734. */
  22735. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  22736. /**
  22737. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  22738. * This property is pertinent only for updatable parametric shapes.
  22739. */
  22740. readonly areNormalsFrozen: boolean;
  22741. /**
  22742. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  22743. * It has no effect at all on other shapes.
  22744. * It prevents the mesh normals from being recomputed on next `positions` array update.
  22745. * Returns the Mesh.
  22746. */
  22747. freezeNormals(): Mesh;
  22748. /**
  22749. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  22750. * It has no effect at all on other shapes.
  22751. * It reactivates the mesh normals computation if it was previously frozen.
  22752. * Returns the Mesh.
  22753. */
  22754. unfreezeNormals(): Mesh;
  22755. /**
  22756. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  22757. */
  22758. overridenInstanceCount: number;
  22759. _preActivate(): Mesh;
  22760. _preActivateForIntermediateRendering(renderId: number): Mesh;
  22761. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  22762. /**
  22763. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22764. * This means the mesh underlying bounding box and sphere are recomputed.
  22765. * Returns the Mesh.
  22766. */
  22767. refreshBoundingInfo(): Mesh;
  22768. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  22769. private _getPositionData(applySkeleton);
  22770. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  22771. subdivide(count: number): void;
  22772. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  22773. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  22774. /**
  22775. * Sets the mesh VertexBuffer.
  22776. * Returns the Mesh.
  22777. */
  22778. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  22779. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  22780. /**
  22781. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  22782. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  22783. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  22784. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  22785. * Returns the Mesh.
  22786. */
  22787. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  22788. /**
  22789. * Creates a un-shared specific occurence of the geometry for the mesh.
  22790. * Returns the Mesh.
  22791. */
  22792. makeGeometryUnique(): Mesh;
  22793. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  22794. /**
  22795. * Update the current index buffer
  22796. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22797. * Returns the Mesh.
  22798. */
  22799. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  22800. /**
  22801. * Invert the geometry to move from a right handed system to a left handed one.
  22802. * Returns the Mesh.
  22803. */
  22804. toLeftHanded(): Mesh;
  22805. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  22806. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  22807. /**
  22808. * Registers for this mesh a javascript function called just before the rendering process.
  22809. * This function is passed the current mesh.
  22810. * Return the Mesh.
  22811. */
  22812. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  22813. /**
  22814. * Disposes a previously registered javascript function called before the rendering.
  22815. * This function is passed the current mesh.
  22816. * Returns the Mesh.
  22817. */
  22818. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  22819. /**
  22820. * Registers for this mesh a javascript function called just after the rendering is complete.
  22821. * This function is passed the current mesh.
  22822. * Returns the Mesh.
  22823. */
  22824. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  22825. /**
  22826. * Disposes a previously registered javascript function called after the rendering.
  22827. * This function is passed the current mesh.
  22828. * Return the Mesh.
  22829. */
  22830. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  22831. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  22832. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  22833. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  22834. /**
  22835. * Triggers the draw call for the mesh.
  22836. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  22837. * Returns the Mesh.
  22838. */
  22839. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  22840. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  22841. /**
  22842. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  22843. */
  22844. getEmittedParticleSystems(): IParticleSystem[];
  22845. /**
  22846. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  22847. */
  22848. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  22849. /**
  22850. * Normalize matrix weights so that all vertices have a total weight set to 1
  22851. */
  22852. cleanMatrixWeights(): void;
  22853. _checkDelayState(): Mesh;
  22854. private _queueLoad(scene);
  22855. /**
  22856. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  22857. */
  22858. isInFrustum(frustumPlanes: Plane[]): boolean;
  22859. /**
  22860. * Sets the mesh material by the material or multiMaterial `id` property.
  22861. * The material `id` is a string identifying the material or the multiMaterial.
  22862. * This method returns the Mesh.
  22863. */
  22864. setMaterialByID(id: string): Mesh;
  22865. /**
  22866. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  22867. */
  22868. getAnimatables(): IAnimatable[];
  22869. /**
  22870. * Modifies the mesh geometry according to the passed transformation matrix.
  22871. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  22872. * The mesh normals are modified accordingly the same transformation.
  22873. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  22874. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22875. * Returns the Mesh.
  22876. */
  22877. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22878. /**
  22879. * Modifies the mesh geometry according to its own current World Matrix.
  22880. * The mesh World Matrix is then reset.
  22881. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22882. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  22883. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22884. * Returns the Mesh.
  22885. */
  22886. bakeCurrentTransformIntoVertices(): Mesh;
  22887. readonly _positions: Nullable<Vector3[]>;
  22888. _resetPointsArrayCache(): Mesh;
  22889. _generatePointsArray(): boolean;
  22890. /**
  22891. * Returns a new Mesh object generated from the current mesh properties.
  22892. * This method must not get confused with createInstance().
  22893. * The parameter `name` is a string, the name given to the new mesh.
  22894. * The optional parameter `newParent` can be any Node object (default `null`).
  22895. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  22896. * 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.
  22897. */
  22898. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22899. /**
  22900. * Releases resources associated with this mesh.
  22901. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22902. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22903. */
  22904. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22905. /**
  22906. * Modifies the mesh geometry according to a displacement map.
  22907. * 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.
  22908. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22909. * This method returns nothing.
  22910. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  22911. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  22912. * 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.
  22913. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  22914. * The parameter `uvScale` is an optional vector2 used to scale UV.
  22915. *
  22916. * Returns the Mesh.
  22917. */
  22918. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  22919. /**
  22920. * Modifies the mesh geometry according to a displacementMap buffer.
  22921. * 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.
  22922. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22923. * This method returns nothing.
  22924. * 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.
  22925. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  22926. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  22927. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  22928. * The parameter `uvScale` is an optional vector2 used to scale UV.
  22929. *
  22930. * Returns the Mesh.
  22931. */
  22932. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  22933. /**
  22934. * Modify the mesh to get a flat shading rendering.
  22935. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22936. * This method returns the Mesh.
  22937. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22938. */
  22939. convertToFlatShadedMesh(): Mesh;
  22940. /**
  22941. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22942. * In other words, more vertices, no more indices and a single bigger VBO.
  22943. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22944. * Returns the Mesh.
  22945. */
  22946. convertToUnIndexedMesh(): Mesh;
  22947. /**
  22948. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  22949. * This method returns the Mesh.
  22950. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22951. */
  22952. flipFaces(flipNormals?: boolean): Mesh;
  22953. /**
  22954. * Creates a new InstancedMesh object from the mesh model.
  22955. * An instance shares the same properties and the same material than its model.
  22956. * Only these properties of each instance can then be set individually :
  22957. * - position
  22958. * - rotation
  22959. * - rotationQuaternion
  22960. * - setPivotMatrix
  22961. * - scaling
  22962. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  22963. * Warning : this method is not supported for Line mesh and LineSystem
  22964. */
  22965. createInstance(name: string): InstancedMesh;
  22966. /**
  22967. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22968. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22969. * This method returns the Mesh.
  22970. */
  22971. synchronizeInstances(): Mesh;
  22972. /**
  22973. * Simplify the mesh according to the given array of settings.
  22974. * Function will return immediately and will simplify async. It returns the Mesh.
  22975. * @param settings a collection of simplification settings.
  22976. * @param parallelProcessing should all levels calculate parallel or one after the other.
  22977. * @param type the type of simplification to run.
  22978. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  22979. */
  22980. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  22981. /**
  22982. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22983. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22984. * This should be used together with the simplification to avoid disappearing triangles.
  22985. * Returns the Mesh.
  22986. * @param successCallback an optional success callback to be called after the optimization finished.
  22987. */
  22988. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22989. serialize(serializationObject: any): void;
  22990. _syncGeometryWithMorphTargetManager(): void;
  22991. /**
  22992. * Returns a new Mesh object parsed from the source provided.
  22993. * The parameter `parsedMesh` is the source.
  22994. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22995. */
  22996. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22997. /**
  22998. * Creates a ribbon mesh.
  22999. * Please consider using the same method from the MeshBuilder class instead.
  23000. * 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.
  23001. *
  23002. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  23003. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23004. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  23005. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  23006. * 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.
  23007. * 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.
  23008. * 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
  23009. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23010. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23011. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23012. */
  23013. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23014. /**
  23015. * Creates a plane polygonal mesh. By default, this is a disc.
  23016. * Please consider using the same method from the MeshBuilder class instead.
  23017. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  23018. * 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.
  23019. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23020. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23021. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23022. */
  23023. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23024. /**
  23025. * Creates a box mesh.
  23026. * Please consider using the same method from the MeshBuilder class instead.
  23027. * The parameter `size` sets the size (float) of each box side (default 1).
  23028. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23029. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23030. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23031. */
  23032. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23033. /**
  23034. * Creates a sphere mesh.
  23035. * Please consider using the same method from the MeshBuilder class instead.
  23036. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  23037. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  23038. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23039. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23040. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23041. */
  23042. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23043. /**
  23044. * Creates a cylinder or a cone mesh.
  23045. * Please consider using the same method from the MeshBuilder class instead.
  23046. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23047. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23048. * 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.
  23049. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23050. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23051. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23052. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23053. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23054. */
  23055. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23056. /**
  23057. * Creates a torus mesh.
  23058. * Please consider using the same method from the MeshBuilder class instead.
  23059. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  23060. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  23061. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  23062. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23063. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23064. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23065. */
  23066. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23067. /**
  23068. * Creates a torus knot mesh.
  23069. * Please consider using the same method from the MeshBuilder class instead.
  23070. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  23071. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  23072. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  23073. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  23074. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23075. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23076. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23077. */
  23078. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23079. /**
  23080. * Creates a line mesh.
  23081. * Please consider using the same method from the MeshBuilder class instead.
  23082. * 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.
  23083. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  23084. * The parameter `points` is an array successive Vector3.
  23085. * 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
  23086. * When updating an instance, remember that only point positions can change, not the number of points.
  23087. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23088. */
  23089. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23090. /**
  23091. * Creates a dashed line mesh.
  23092. * Please consider using the same method from the MeshBuilder class instead.
  23093. * 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.
  23094. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  23095. * The parameter `points` is an array successive Vector3.
  23096. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  23097. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  23098. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  23099. * 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
  23100. * When updating an instance, remember that only point positions can change, not the number of points.
  23101. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23102. */
  23103. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23104. /**
  23105. * Creates a polygon mesh.
  23106. * Please consider using the same method from the MeshBuilder class instead.
  23107. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23108. * 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.
  23109. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23110. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23111. * Remember you can only change the shape positions, not their number when updating a polygon.
  23112. */
  23113. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  23114. /**
  23115. * Creates an extruded polygon mesh, with depth in the Y direction.
  23116. * Please consider using the same method from the MeshBuilder class instead.
  23117. */
  23118. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  23119. /**
  23120. * Creates an extruded shape mesh.
  23121. * 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.
  23122. * Please consider using the same method from the MeshBuilder class instead.
  23123. *
  23124. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23125. * 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
  23126. * extruded along the Z axis.
  23127. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23128. * 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.
  23129. * The parameter `scale` (float, default 1) is the value to scale the shape.
  23130. * 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
  23131. * 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
  23132. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23133. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23134. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23135. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23136. */
  23137. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23138. /**
  23139. * Creates an custom extruded shape mesh.
  23140. * 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.
  23141. * Please consider using the same method from the MeshBuilder class instead.
  23142. *
  23143. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23144. * 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
  23145. * extruded along the Z axis.
  23146. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23147. * 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
  23148. * and the distance of this point from the begining of the path :
  23149. * ```javascript
  23150. * var rotationFunction = function(i, distance) {
  23151. * // do things
  23152. * return rotationValue; }
  23153. * ```
  23154. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23155. * 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
  23156. * and the distance of this point from the begining of the path :
  23157. * ```javascript
  23158. * var scaleFunction = function(i, distance) {
  23159. * // do things
  23160. * return scaleValue;}
  23161. * ```
  23162. * It must returns a float value that will be the scale value applied to the shape on each path point.
  23163. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  23164. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  23165. * 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
  23166. * 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
  23167. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23168. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23169. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23170. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23171. */
  23172. 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;
  23173. /**
  23174. * Creates lathe mesh.
  23175. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  23176. * Please consider using the same method from the MeshBuilder class instead.
  23177. * 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
  23178. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  23179. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  23180. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  23181. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23182. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23183. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23184. */
  23185. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23186. /**
  23187. * Creates a plane mesh.
  23188. * Please consider using the same method from the MeshBuilder class instead.
  23189. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  23190. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23191. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23192. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23193. */
  23194. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23195. /**
  23196. * Creates a ground mesh.
  23197. * Please consider using the same method from the MeshBuilder class instead.
  23198. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  23199. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  23200. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23201. */
  23202. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  23203. /**
  23204. * Creates a tiled ground mesh.
  23205. * Please consider using the same method from the MeshBuilder class instead.
  23206. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  23207. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  23208. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  23209. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  23210. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  23211. * numbers of subdivisions on the ground width and height of each tile.
  23212. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23213. */
  23214. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  23215. w: number;
  23216. h: number;
  23217. }, precision: {
  23218. w: number;
  23219. h: number;
  23220. }, scene: Scene, updatable?: boolean): Mesh;
  23221. /**
  23222. * Creates a ground mesh from a height map.
  23223. * tuto : http://doc.babylonjs.com/babylon101/height_map
  23224. * Please consider using the same method from the MeshBuilder class instead.
  23225. * The parameter `url` sets the URL of the height map image resource.
  23226. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23227. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23228. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23229. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23230. * 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).
  23231. * This function is passed the newly built mesh :
  23232. * ```javascript
  23233. * function(mesh) { // do things
  23234. * return; }
  23235. * ```
  23236. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23237. */
  23238. 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;
  23239. /**
  23240. * Creates a tube mesh.
  23241. * 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.
  23242. * Please consider using the same method from the MeshBuilder class instead.
  23243. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  23244. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  23245. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  23246. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  23247. * 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.
  23248. * It must return a radius value (positive float) :
  23249. * ```javascript
  23250. * var radiusFunction = function(i, distance) {
  23251. * // do things
  23252. * return radius; }
  23253. * ```
  23254. * 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
  23255. * 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
  23256. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23257. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23258. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23259. */
  23260. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  23261. (i: number, distance: number): number;
  23262. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23263. /**
  23264. * Creates a polyhedron mesh.
  23265. * Please consider using the same method from the MeshBuilder class instead.
  23266. * 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
  23267. * to choose the wanted type.
  23268. * The parameter `size` (positive float, default 1) sets the polygon size.
  23269. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  23270. * 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`.
  23271. * 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
  23272. * 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)`).
  23273. * 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
  23274. * 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.
  23275. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23276. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23277. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23278. */
  23279. static CreatePolyhedron(name: string, options: {
  23280. type?: number;
  23281. size?: number;
  23282. sizeX?: number;
  23283. sizeY?: number;
  23284. sizeZ?: number;
  23285. custom?: any;
  23286. faceUV?: Vector4[];
  23287. faceColors?: Color4[];
  23288. updatable?: boolean;
  23289. sideOrientation?: number;
  23290. }, scene: Scene): Mesh;
  23291. /**
  23292. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  23293. * Please consider using the same method from the MeshBuilder class instead.
  23294. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  23295. * 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`).
  23296. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  23297. * 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.
  23298. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23299. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23300. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23301. */
  23302. static CreateIcoSphere(name: string, options: {
  23303. radius?: number;
  23304. flat?: boolean;
  23305. subdivisions?: number;
  23306. sideOrientation?: number;
  23307. updatable?: boolean;
  23308. }, scene: Scene): Mesh;
  23309. /**
  23310. * Creates a decal mesh.
  23311. * Please consider using the same method from the MeshBuilder class instead.
  23312. * 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.
  23313. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  23314. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  23315. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  23316. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  23317. */
  23318. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  23319. /**
  23320. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  23321. */
  23322. setPositionsForCPUSkinning(): Float32Array;
  23323. /**
  23324. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  23325. */
  23326. setNormalsForCPUSkinning(): Float32Array;
  23327. /**
  23328. * Updates the vertex buffer by applying transformation from the bones.
  23329. * Returns the Mesh.
  23330. *
  23331. * @param {skeleton} skeleton to apply
  23332. */
  23333. applySkeleton(skeleton: Skeleton): Mesh;
  23334. /**
  23335. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  23336. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  23337. */
  23338. static MinMax(meshes: AbstractMesh[]): {
  23339. min: Vector3;
  23340. max: Vector3;
  23341. };
  23342. /**
  23343. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  23344. */
  23345. static Center(meshesOrMinMaxVector: {
  23346. min: Vector3;
  23347. max: Vector3;
  23348. } | AbstractMesh[]): Vector3;
  23349. /**
  23350. * Merge the array of meshes into a single mesh for performance reasons.
  23351. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  23352. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  23353. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  23354. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  23355. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  23356. */
  23357. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  23358. }
  23359. }
  23360. declare module BABYLON {
  23361. /**
  23362. * Define an interface for all classes that will get and set the data on vertices
  23363. */
  23364. interface IGetSetVerticesData {
  23365. isVerticesDataPresent(kind: string): boolean;
  23366. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23367. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  23368. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23369. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23370. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23371. }
  23372. /**
  23373. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23374. */
  23375. class VertexData {
  23376. /**
  23377. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23378. */
  23379. positions: Nullable<FloatArray>;
  23380. /**
  23381. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23382. */
  23383. normals: Nullable<FloatArray>;
  23384. /**
  23385. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23386. */
  23387. tangents: Nullable<FloatArray>;
  23388. /**
  23389. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23390. */
  23391. uvs: Nullable<FloatArray>;
  23392. /**
  23393. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23394. */
  23395. uvs2: Nullable<FloatArray>;
  23396. /**
  23397. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23398. */
  23399. uvs3: Nullable<FloatArray>;
  23400. /**
  23401. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23402. */
  23403. uvs4: Nullable<FloatArray>;
  23404. /**
  23405. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23406. */
  23407. uvs5: Nullable<FloatArray>;
  23408. /**
  23409. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23410. */
  23411. uvs6: Nullable<FloatArray>;
  23412. /**
  23413. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23414. */
  23415. colors: Nullable<FloatArray>;
  23416. /**
  23417. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  23418. */
  23419. matricesIndices: Nullable<FloatArray>;
  23420. /**
  23421. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23422. */
  23423. matricesWeights: Nullable<FloatArray>;
  23424. /**
  23425. * An array extending the number of possible indices
  23426. */
  23427. matricesIndicesExtra: Nullable<FloatArray>;
  23428. /**
  23429. * An array extending the number of possible weights when the number of indices is extended
  23430. */
  23431. matricesWeightsExtra: Nullable<FloatArray>;
  23432. /**
  23433. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23434. */
  23435. indices: Nullable<IndicesArray>;
  23436. /**
  23437. * Uses the passed data array to set the set the values for the specified kind of data
  23438. * @param data a linear array of floating numbers
  23439. * @param kind the type of data that is being set, eg positions, colors etc
  23440. */
  23441. set(data: FloatArray, kind: string): void;
  23442. /**
  23443. * Associates the vertexData to the passed Mesh.
  23444. * Sets it as updatable or not (default `false`)
  23445. * @param mesh the mesh the vertexData is applied to
  23446. * @param updatable when used and having the value true allows new data to update the vertexData
  23447. * @returns the VertexData
  23448. */
  23449. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23450. /**
  23451. * Associates the vertexData to the passed Geometry.
  23452. * Sets it as updatable or not (default `false`)
  23453. * @param geometry the geometry the vertexData is applied to
  23454. * @param updatable when used and having the value true allows new data to update the vertexData
  23455. * @returns VertexData
  23456. */
  23457. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23458. /**
  23459. * Updates the associated mesh
  23460. * @param mesh the mesh to be updated
  23461. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23462. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  23463. * @returns VertexData
  23464. */
  23465. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  23466. /**
  23467. * Updates the associated geometry
  23468. * @param geometry the geometry to be updated
  23469. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23470. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  23471. * @returns VertexData.
  23472. */
  23473. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  23474. private _applyTo(meshOrGeometry, updatable?);
  23475. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  23476. /**
  23477. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23478. * @param matrix the transforming matrix
  23479. * @returns the VertexData
  23480. */
  23481. transform(matrix: Matrix): VertexData;
  23482. /**
  23483. * Merges the passed VertexData into the current one
  23484. * @param other the VertexData to be merged into the current one
  23485. * @returns the modified VertexData
  23486. */
  23487. merge(other: VertexData): VertexData;
  23488. private _mergeElement(source, other);
  23489. private _validate();
  23490. /**
  23491. * Serializes the VertexData
  23492. * @returns a serialized object
  23493. */
  23494. serialize(): any;
  23495. /**
  23496. * Extracts the vertexData from a mesh
  23497. * @param mesh the mesh from which to extract the VertexData
  23498. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23499. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23500. * @returns the object VertexData associated to the passed mesh
  23501. */
  23502. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23503. /**
  23504. * Extracts the vertexData from the geometry
  23505. * @param geometry the geometry from which to extract the VertexData
  23506. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23507. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23508. * @returns the object VertexData associated to the passed mesh
  23509. */
  23510. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23511. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  23512. /**
  23513. * Creates the VertexData for a Ribbon
  23514. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23515. * * pathArray array of paths, each of which an array of successive Vector3
  23516. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23517. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23518. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  23519. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23520. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23521. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23522. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23523. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23524. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23525. * @returns the VertexData of the ribbon
  23526. */
  23527. static CreateRibbon(options: {
  23528. pathArray: Vector3[][];
  23529. closeArray?: boolean;
  23530. closePath?: boolean;
  23531. offset?: number;
  23532. sideOrientation?: number;
  23533. frontUVs?: Vector4;
  23534. backUVs?: Vector4;
  23535. invertUV?: boolean;
  23536. uvs?: Vector2[];
  23537. colors?: Color4[];
  23538. }): VertexData;
  23539. /**
  23540. * Creates the VertexData for a box
  23541. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23542. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23543. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23544. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23545. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23546. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23547. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23548. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23549. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23550. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23551. * @returns the VertexData of the box
  23552. */
  23553. static CreateBox(options: {
  23554. size?: number;
  23555. width?: number;
  23556. height?: number;
  23557. depth?: number;
  23558. faceUV?: Vector4[];
  23559. faceColors?: Color4[];
  23560. sideOrientation?: number;
  23561. frontUVs?: Vector4;
  23562. backUVs?: Vector4;
  23563. }): VertexData;
  23564. /**
  23565. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23566. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23567. * * segments sets the number of horizontal strips optional, default 32
  23568. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23569. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23570. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23571. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23572. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  23573. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  23574. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23575. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23576. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23577. * @returns the VertexData of the ellipsoid
  23578. */
  23579. static CreateSphere(options: {
  23580. segments?: number;
  23581. diameter?: number;
  23582. diameterX?: number;
  23583. diameterY?: number;
  23584. diameterZ?: number;
  23585. arc?: number;
  23586. slice?: number;
  23587. sideOrientation?: number;
  23588. frontUVs?: Vector4;
  23589. backUVs?: Vector4;
  23590. }): VertexData;
  23591. /**
  23592. * Creates the VertexData for a cylinder, cone or prism
  23593. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23594. * * height sets the height (y direction) of the cylinder, optional, default 2
  23595. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23596. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23597. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23598. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23599. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23600. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  23601. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23602. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23603. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23604. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23605. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23606. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23607. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23608. * @returns the VertexData of the cylinder, cone or prism
  23609. */
  23610. static CreateCylinder(options: {
  23611. height?: number;
  23612. diameterTop?: number;
  23613. diameterBottom?: number;
  23614. diameter?: number;
  23615. tessellation?: number;
  23616. subdivisions?: number;
  23617. arc?: number;
  23618. faceColors?: Color4[];
  23619. faceUV?: Vector4[];
  23620. hasRings?: boolean;
  23621. enclose?: boolean;
  23622. sideOrientation?: number;
  23623. frontUVs?: Vector4;
  23624. backUVs?: Vector4;
  23625. }): VertexData;
  23626. /**
  23627. * Creates the VertexData for a torus
  23628. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23629. * * diameter the diameter of the torus, optional default 1
  23630. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23631. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23632. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23633. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23634. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23635. * @returns the VertexData of the torus
  23636. */
  23637. static CreateTorus(options: {
  23638. diameter?: number;
  23639. thickness?: number;
  23640. tessellation?: number;
  23641. sideOrientation?: number;
  23642. frontUVs?: Vector4;
  23643. backUVs?: Vector4;
  23644. }): VertexData;
  23645. /**
  23646. * Creates the VertexData of the LineSystem
  23647. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23648. * - lines an array of lines, each line being an array of successive Vector3
  23649. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23650. * @returns the VertexData of the LineSystem
  23651. */
  23652. static CreateLineSystem(options: {
  23653. lines: Vector3[][];
  23654. colors?: Nullable<Color4[][]>;
  23655. }): VertexData;
  23656. /**
  23657. * Create the VertexData for a DashedLines
  23658. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23659. * - points an array successive Vector3
  23660. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23661. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23662. * - dashNb the intended total number of dashes, optional, default 200
  23663. * @returns the VertexData for the DashedLines
  23664. */
  23665. static CreateDashedLines(options: {
  23666. points: Vector3[];
  23667. dashSize?: number;
  23668. gapSize?: number;
  23669. dashNb?: number;
  23670. }): VertexData;
  23671. /**
  23672. * Creates the VertexData for a Ground
  23673. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23674. * - width the width (x direction) of the ground, optional, default 1
  23675. * - height the height (z direction) of the ground, optional, default 1
  23676. * - subdivisions the number of subdivisions per side, optional, default 1
  23677. * @returns the VertexData of the Ground
  23678. */
  23679. static CreateGround(options: {
  23680. width?: number;
  23681. height?: number;
  23682. subdivisions?: number;
  23683. subdivisionsX?: number;
  23684. subdivisionsY?: number;
  23685. }): VertexData;
  23686. /**
  23687. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23688. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23689. * * xmin the ground minimum X coordinate, optional, default -1
  23690. * * zmin the ground minimum Z coordinate, optional, default -1
  23691. * * xmax the ground maximum X coordinate, optional, default 1
  23692. * * zmax the ground maximum Z coordinate, optional, default 1
  23693. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  23694. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  23695. * @returns the VertexData of the TiledGround
  23696. */
  23697. static CreateTiledGround(options: {
  23698. xmin: number;
  23699. zmin: number;
  23700. xmax: number;
  23701. zmax: number;
  23702. subdivisions?: {
  23703. w: number;
  23704. h: number;
  23705. };
  23706. precision?: {
  23707. w: number;
  23708. h: number;
  23709. };
  23710. }): VertexData;
  23711. /**
  23712. * Creates the VertexData of the Ground designed from a heightmap
  23713. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23714. * * width the width (x direction) of the ground
  23715. * * height the height (z direction) of the ground
  23716. * * subdivisions the number of subdivisions per side
  23717. * * minHeight the minimum altitude on the ground, optional, default 0
  23718. * * maxHeight the maximum altitude on the ground, optional default 1
  23719. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23720. * * buffer the array holding the image color data
  23721. * * bufferWidth the width of image
  23722. * * bufferHeight the height of image
  23723. * @returns the VertexData of the Ground designed from a heightmap
  23724. */
  23725. static CreateGroundFromHeightMap(options: {
  23726. width: number;
  23727. height: number;
  23728. subdivisions: number;
  23729. minHeight: number;
  23730. maxHeight: number;
  23731. colorFilter: Color3;
  23732. buffer: Uint8Array;
  23733. bufferWidth: number;
  23734. bufferHeight: number;
  23735. }): VertexData;
  23736. /**
  23737. * Creates the VertexData for a Plane
  23738. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23739. * * size sets the width and height of the plane to the value of size, optional default 1
  23740. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23741. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23742. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23743. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23744. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23745. * @returns the VertexData of the box
  23746. */
  23747. static CreatePlane(options: {
  23748. size?: number;
  23749. width?: number;
  23750. height?: number;
  23751. sideOrientation?: number;
  23752. frontUVs?: Vector4;
  23753. backUVs?: Vector4;
  23754. }): VertexData;
  23755. /**
  23756. * Creates the VertexData of the Disc or regular Polygon
  23757. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23758. * * radius the radius of the disc, optional default 0.5
  23759. * * tessellation the number of polygon sides, optional, default 64
  23760. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  23761. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23762. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23763. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23764. * @returns the VertexData of the box
  23765. */
  23766. static CreateDisc(options: {
  23767. radius?: number;
  23768. tessellation?: number;
  23769. arc?: number;
  23770. sideOrientation?: number;
  23771. frontUVs?: Vector4;
  23772. backUVs?: Vector4;
  23773. }): VertexData;
  23774. /**
  23775. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23776. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23777. * @param polygon a mesh built from polygonTriangulation.build()
  23778. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23779. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23780. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23781. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23782. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23783. * @returns the VertexData of the Polygon
  23784. */
  23785. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23786. /**
  23787. * Creates the VertexData of the IcoSphere
  23788. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23789. * * radius the radius of the IcoSphere, optional default 1
  23790. * * radiusX allows stretching in the x direction, optional, default radius
  23791. * * radiusY allows stretching in the y direction, optional, default radius
  23792. * * radiusZ allows stretching in the z direction, optional, default radius
  23793. * * flat when true creates a flat shaded mesh, optional, default true
  23794. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23795. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23796. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23797. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23798. * @returns the VertexData of the IcoSphere
  23799. */
  23800. static CreateIcoSphere(options: {
  23801. radius?: number;
  23802. radiusX?: number;
  23803. radiusY?: number;
  23804. radiusZ?: number;
  23805. flat?: boolean;
  23806. subdivisions?: number;
  23807. sideOrientation?: number;
  23808. frontUVs?: Vector4;
  23809. backUVs?: Vector4;
  23810. }): VertexData;
  23811. /**
  23812. * Creates the VertexData for a Polyhedron
  23813. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23814. * * type provided types are:
  23815. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23816. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  23817. * * size the size of the IcoSphere, optional default 1
  23818. * * sizeX allows stretching in the x direction, optional, default size
  23819. * * sizeY allows stretching in the y direction, optional, default size
  23820. * * sizeZ allows stretching in the z direction, optional, default size
  23821. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  23822. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23823. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23824. * * flat when true creates a flat shaded mesh, optional, default true
  23825. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23826. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23827. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23828. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23829. * @returns the VertexData of the Polyhedron
  23830. */
  23831. static CreatePolyhedron(options: {
  23832. type?: number;
  23833. size?: number;
  23834. sizeX?: number;
  23835. sizeY?: number;
  23836. sizeZ?: number;
  23837. custom?: any;
  23838. faceUV?: Vector4[];
  23839. faceColors?: Color4[];
  23840. flat?: boolean;
  23841. sideOrientation?: number;
  23842. frontUVs?: Vector4;
  23843. backUVs?: Vector4;
  23844. }): VertexData;
  23845. /**
  23846. * Creates the VertexData for a TorusKnot
  23847. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23848. * * radius the radius of the torus knot, optional, default 2
  23849. * * tube the thickness of the tube, optional, default 0.5
  23850. * * radialSegments the number of sides on each tube segments, optional, default 32
  23851. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23852. * * p the number of windings around the z axis, optional, default 2
  23853. * * q the number of windings around the x axis, optional, default 3
  23854. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23855. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23856. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23857. * @returns the VertexData of the Torus Knot
  23858. */
  23859. static CreateTorusKnot(options: {
  23860. radius?: number;
  23861. tube?: number;
  23862. radialSegments?: number;
  23863. tubularSegments?: number;
  23864. p?: number;
  23865. q?: number;
  23866. sideOrientation?: number;
  23867. frontUVs?: Vector4;
  23868. backUVs?: Vector4;
  23869. }): VertexData;
  23870. /**
  23871. * Compute normals for given positions and indices
  23872. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23873. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23874. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23875. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23876. * * facetNormals : optional array of facet normals (vector3)
  23877. * * facetPositions : optional array of facet positions (vector3)
  23878. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23879. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23880. * * bInfo : optional bounding info, required for facetPartitioning computation
  23881. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23882. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23883. * * useRightHandedSystem: optional boolean to for right handed system computation
  23884. * * depthSort : optional boolean to enable the facet depth sort computation
  23885. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23886. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23887. */
  23888. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23889. facetNormals?: any;
  23890. facetPositions?: any;
  23891. facetPartitioning?: any;
  23892. ratio?: number;
  23893. bInfo?: any;
  23894. bbSize?: Vector3;
  23895. subDiv?: any;
  23896. useRightHandedSystem?: boolean;
  23897. depthSort?: boolean;
  23898. distanceTo?: Vector3;
  23899. depthSortedFacets?: any;
  23900. }): void;
  23901. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  23902. /**
  23903. * Applies VertexData created from the imported parameters to the geometry
  23904. * @param parsedVertexData the parsed data from an imported file
  23905. * @param geometry the geometry to apply the VertexData to
  23906. */
  23907. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23908. }
  23909. }
  23910. declare module BABYLON {
  23911. /**
  23912. * Class containing static functions to help procedurally build meshes
  23913. */
  23914. class MeshBuilder {
  23915. private static updateSideOrientation(orientation?);
  23916. /**
  23917. * Creates a box mesh
  23918. * * The parameter `size` sets the size (float) of each box side (default 1)
  23919. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  23920. * * 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)
  23921. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23925. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  23926. * @param name defines the name of the mesh
  23927. * @param options defines the options used to create the mesh
  23928. * @param scene defines the hosting scene
  23929. * @returns the box mesh
  23930. */
  23931. static CreateBox(name: string, options: {
  23932. size?: number;
  23933. width?: number;
  23934. height?: number;
  23935. depth?: number;
  23936. faceUV?: Vector4[];
  23937. faceColors?: Color4[];
  23938. sideOrientation?: number;
  23939. frontUVs?: Vector4;
  23940. backUVs?: Vector4;
  23941. updatable?: boolean;
  23942. }, scene?: Nullable<Scene>): Mesh;
  23943. /**
  23944. * Creates a sphere mesh
  23945. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23946. * * 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`)
  23947. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23948. * * 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
  23949. * * 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)
  23950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23953. * @param name defines the name of the mesh
  23954. * @param options defines the options used to create the mesh
  23955. * @param scene defines the hosting scene
  23956. * @returns the sphere mesh
  23957. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  23958. */
  23959. static CreateSphere(name: string, options: {
  23960. segments?: number;
  23961. diameter?: number;
  23962. diameterX?: number;
  23963. diameterY?: number;
  23964. diameterZ?: number;
  23965. arc?: number;
  23966. slice?: number;
  23967. sideOrientation?: number;
  23968. frontUVs?: Vector4;
  23969. backUVs?: Vector4;
  23970. updatable?: boolean;
  23971. }, scene: any): Mesh;
  23972. /**
  23973. * Creates a plane polygonal mesh. By default, this is a disc
  23974. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23975. * * 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
  23976. * * 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
  23977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23980. * @param name defines the name of the mesh
  23981. * @param options defines the options used to create the mesh
  23982. * @param scene defines the hosting scene
  23983. * @returns the plane polygonal mesh
  23984. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23985. */
  23986. static CreateDisc(name: string, options: {
  23987. radius?: number;
  23988. tessellation?: number;
  23989. arc?: number;
  23990. updatable?: boolean;
  23991. sideOrientation?: number;
  23992. frontUVs?: Vector4;
  23993. backUVs?: Vector4;
  23994. }, scene?: Nullable<Scene>): Mesh;
  23995. /**
  23996. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23997. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23998. * * 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`)
  23999. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24000. * * 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
  24001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24004. * @param name defines the name of the mesh
  24005. * @param options defines the options used to create the mesh
  24006. * @param scene defines the hosting scene
  24007. * @returns the icosahedron mesh
  24008. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24009. */
  24010. static CreateIcoSphere(name: string, options: {
  24011. radius?: number;
  24012. radiusX?: number;
  24013. radiusY?: number;
  24014. radiusZ?: number;
  24015. flat?: boolean;
  24016. subdivisions?: number;
  24017. sideOrientation?: number;
  24018. frontUVs?: Vector4;
  24019. backUVs?: Vector4;
  24020. updatable?: boolean;
  24021. }, scene: Scene): Mesh;
  24022. /**
  24023. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  24024. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  24025. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  24026. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  24027. * * 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
  24028. * * 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
  24029. * * 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
  24030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24033. * * 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
  24034. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  24035. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  24036. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  24037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24038. * @param name defines the name of the mesh
  24039. * @param options defines the options used to create the mesh
  24040. * @param scene defines the hosting scene
  24041. * @returns the ribbon mesh
  24042. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  24043. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  24044. */
  24045. static CreateRibbon(name: string, options: {
  24046. pathArray: Vector3[][];
  24047. closeArray?: boolean;
  24048. closePath?: boolean;
  24049. offset?: number;
  24050. updatable?: boolean;
  24051. sideOrientation?: number;
  24052. frontUVs?: Vector4;
  24053. backUVs?: Vector4;
  24054. instance?: Mesh;
  24055. invertUV?: boolean;
  24056. uvs?: Vector2[];
  24057. colors?: Color4[];
  24058. }, scene?: Nullable<Scene>): Mesh;
  24059. /**
  24060. * Creates a cylinder or a cone mesh
  24061. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  24062. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  24063. * * 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.
  24064. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  24065. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  24066. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  24067. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  24068. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  24069. * * 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).
  24070. * * 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
  24071. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  24072. * * 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
  24073. * * 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.
  24074. * * If `enclose` is false, a ring surface is one element.
  24075. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  24076. * * 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
  24077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24080. * @param name defines the name of the mesh
  24081. * @param options defines the options used to create the mesh
  24082. * @param scene defines the hosting scene
  24083. * @returns the cylinder mesh
  24084. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  24085. */
  24086. static CreateCylinder(name: string, options: {
  24087. height?: number;
  24088. diameterTop?: number;
  24089. diameterBottom?: number;
  24090. diameter?: number;
  24091. tessellation?: number;
  24092. subdivisions?: number;
  24093. arc?: number;
  24094. faceColors?: Color4[];
  24095. faceUV?: Vector4[];
  24096. updatable?: boolean;
  24097. hasRings?: boolean;
  24098. enclose?: boolean;
  24099. sideOrientation?: number;
  24100. frontUVs?: Vector4;
  24101. backUVs?: Vector4;
  24102. }, scene: any): Mesh;
  24103. /**
  24104. * Creates a torus mesh
  24105. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  24106. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  24107. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  24108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24111. * @param name defines the name of the mesh
  24112. * @param options defines the options used to create the mesh
  24113. * @param scene defines the hosting scene
  24114. * @returns the torus mesh
  24115. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  24116. */
  24117. static CreateTorus(name: string, options: {
  24118. diameter?: number;
  24119. thickness?: number;
  24120. tessellation?: number;
  24121. updatable?: boolean;
  24122. sideOrientation?: number;
  24123. frontUVs?: Vector4;
  24124. backUVs?: Vector4;
  24125. }, scene: any): Mesh;
  24126. /**
  24127. * Creates a torus knot mesh
  24128. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  24129. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  24130. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  24131. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  24132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24135. * @param name defines the name of the mesh
  24136. * @param options defines the options used to create the mesh
  24137. * @param scene defines the hosting scene
  24138. * @returns the torus knot mesh
  24139. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  24140. */
  24141. static CreateTorusKnot(name: string, options: {
  24142. radius?: number;
  24143. tube?: number;
  24144. radialSegments?: number;
  24145. tubularSegments?: number;
  24146. p?: number;
  24147. q?: number;
  24148. updatable?: boolean;
  24149. sideOrientation?: number;
  24150. frontUVs?: Vector4;
  24151. backUVs?: Vector4;
  24152. }, scene: any): Mesh;
  24153. /**
  24154. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  24155. * * 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
  24156. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  24157. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  24158. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  24159. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  24160. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  24161. * * 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
  24162. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  24163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24164. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  24165. * @param name defines the name of the new line system
  24166. * @param options defines the options used to create the line system
  24167. * @param scene defines the hosting scene
  24168. * @returns a new line system mesh
  24169. */
  24170. static CreateLineSystem(name: string, options: {
  24171. lines: Vector3[][];
  24172. updatable?: boolean;
  24173. instance?: Nullable<LinesMesh>;
  24174. colors?: Nullable<Color4[][]>;
  24175. useVertexAlpha?: boolean;
  24176. }, scene: Nullable<Scene>): LinesMesh;
  24177. /**
  24178. * Creates a line mesh
  24179. * 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
  24180. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  24181. * * The parameter `points` is an array successive Vector3
  24182. * * 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
  24183. * * The optional parameter `colors` is an array of successive Color4, one per line point
  24184. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  24185. * * When updating an instance, remember that only point positions can change, not the number of points
  24186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24187. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  24188. * @param name defines the name of the new line system
  24189. * @param options defines the options used to create the line system
  24190. * @param scene defines the hosting scene
  24191. * @returns a new line mesh
  24192. */
  24193. static CreateLines(name: string, options: {
  24194. points: Vector3[];
  24195. updatable?: boolean;
  24196. instance?: Nullable<LinesMesh>;
  24197. colors?: Color4[];
  24198. useVertexAlpha?: boolean;
  24199. }, scene?: Nullable<Scene>): LinesMesh;
  24200. /**
  24201. * Creates a dashed line mesh
  24202. * * 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
  24203. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  24204. * * The parameter `points` is an array successive Vector3
  24205. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  24206. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  24207. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24208. * * 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
  24209. * * When updating an instance, remember that only point positions can change, not the number of points
  24210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24211. * @param name defines the name of the mesh
  24212. * @param options defines the options used to create the mesh
  24213. * @param scene defines the hosting scene
  24214. * @returns the dashed line mesh
  24215. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  24216. */
  24217. static CreateDashedLines(name: string, options: {
  24218. points: Vector3[];
  24219. dashSize?: number;
  24220. gapSize?: number;
  24221. dashNb?: number;
  24222. updatable?: boolean;
  24223. instance?: LinesMesh;
  24224. }, scene?: Nullable<Scene>): LinesMesh;
  24225. /**
  24226. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  24227. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  24228. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24229. * * 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.
  24230. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  24231. * * 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
  24232. * * 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
  24233. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  24234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  24237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24238. * @param name defines the name of the mesh
  24239. * @param options defines the options used to create the mesh
  24240. * @param scene defines the hosting scene
  24241. * @returns the extruded shape mesh
  24242. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  24243. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24244. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24245. */
  24246. static ExtrudeShape(name: string, options: {
  24247. shape: Vector3[];
  24248. path: Vector3[];
  24249. scale?: number;
  24250. rotation?: number;
  24251. cap?: number;
  24252. updatable?: boolean;
  24253. sideOrientation?: number;
  24254. frontUVs?: Vector4;
  24255. backUVs?: Vector4;
  24256. instance?: Mesh;
  24257. invertUV?: boolean;
  24258. }, scene?: Nullable<Scene>): Mesh;
  24259. /**
  24260. * Creates an custom extruded shape mesh.
  24261. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  24262. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  24263. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24264. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  24265. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  24266. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  24267. * * It must returns a float value that will be the scale value applied to the shape on each path point
  24268. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24269. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  24270. * * 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
  24271. * * 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
  24272. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  24273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24277. * @param name defines the name of the mesh
  24278. * @param options defines the options used to create the mesh
  24279. * @param scene defines the hosting scene
  24280. * @returns the custom extruded shape mesh
  24281. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  24282. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  24283. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24284. */
  24285. static ExtrudeShapeCustom(name: string, options: {
  24286. shape: Vector3[];
  24287. path: Vector3[];
  24288. scaleFunction?: any;
  24289. rotationFunction?: any;
  24290. ribbonCloseArray?: boolean;
  24291. ribbonClosePath?: boolean;
  24292. cap?: number;
  24293. updatable?: boolean;
  24294. sideOrientation?: number;
  24295. frontUVs?: Vector4;
  24296. backUVs?: Vector4;
  24297. instance?: Mesh;
  24298. invertUV?: boolean;
  24299. }, scene: Scene): Mesh;
  24300. /**
  24301. * Creates lathe mesh.
  24302. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  24303. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  24304. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  24305. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  24306. * * 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
  24307. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  24308. * * 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
  24309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24311. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24313. * @param name defines the name of the mesh
  24314. * @param options defines the options used to create the mesh
  24315. * @param scene defines the hosting scene
  24316. * @returns the lathe mesh
  24317. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  24318. */
  24319. static CreateLathe(name: string, options: {
  24320. shape: Vector3[];
  24321. radius?: number;
  24322. tessellation?: number;
  24323. arc?: number;
  24324. closed?: boolean;
  24325. updatable?: boolean;
  24326. sideOrientation?: number;
  24327. frontUVs?: Vector4;
  24328. backUVs?: Vector4;
  24329. cap?: number;
  24330. invertUV?: boolean;
  24331. }, scene: Scene): Mesh;
  24332. /**
  24333. * Creates a plane mesh
  24334. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  24335. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  24336. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  24337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24340. * @param name defines the name of the mesh
  24341. * @param options defines the options used to create the mesh
  24342. * @param scene defines the hosting scene
  24343. * @returns the plane mesh
  24344. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  24345. */
  24346. static CreatePlane(name: string, options: {
  24347. size?: number;
  24348. width?: number;
  24349. height?: number;
  24350. sideOrientation?: number;
  24351. frontUVs?: Vector4;
  24352. backUVs?: Vector4;
  24353. updatable?: boolean;
  24354. sourcePlane?: Plane;
  24355. }, scene: Scene): Mesh;
  24356. /**
  24357. * Creates a ground mesh
  24358. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  24359. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  24360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24361. * @param name defines the name of the mesh
  24362. * @param options defines the options used to create the mesh
  24363. * @param scene defines the hosting scene
  24364. * @returns the ground mesh
  24365. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  24366. */
  24367. static CreateGround(name: string, options: {
  24368. width?: number;
  24369. height?: number;
  24370. subdivisions?: number;
  24371. subdivisionsX?: number;
  24372. subdivisionsY?: number;
  24373. updatable?: boolean;
  24374. }, scene: any): Mesh;
  24375. /**
  24376. * Creates a tiled ground mesh
  24377. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  24378. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  24379. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  24380. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  24381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24382. * @param name defines the name of the mesh
  24383. * @param options defines the options used to create the mesh
  24384. * @param scene defines the hosting scene
  24385. * @returns the tiled ground mesh
  24386. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  24387. */
  24388. static CreateTiledGround(name: string, options: {
  24389. xmin: number;
  24390. zmin: number;
  24391. xmax: number;
  24392. zmax: number;
  24393. subdivisions?: {
  24394. w: number;
  24395. h: number;
  24396. };
  24397. precision?: {
  24398. w: number;
  24399. h: number;
  24400. };
  24401. updatable?: boolean;
  24402. }, scene: Scene): Mesh;
  24403. /**
  24404. * Creates a ground mesh from a height map
  24405. * * The parameter `url` sets the URL of the height map image resource.
  24406. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  24407. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  24408. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  24409. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  24410. * * 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.
  24411. * * 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).
  24412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24413. * @param name defines the name of the mesh
  24414. * @param url defines the url to the height map
  24415. * @param options defines the options used to create the mesh
  24416. * @param scene defines the hosting scene
  24417. * @returns the ground mesh
  24418. * @see http://doc.babylonjs.com/babylon101/height_map
  24419. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  24420. */
  24421. static CreateGroundFromHeightMap(name: string, url: string, options: {
  24422. width?: number;
  24423. height?: number;
  24424. subdivisions?: number;
  24425. minHeight?: number;
  24426. maxHeight?: number;
  24427. colorFilter?: Color3;
  24428. updatable?: boolean;
  24429. onReady?: (mesh: GroundMesh) => void;
  24430. }, scene: Scene): GroundMesh;
  24431. /**
  24432. * Creates a polygon mesh
  24433. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  24434. * * 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
  24435. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24437. * * 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)
  24438. * * Remember you can only change the shape positions, not their number when updating a polygon
  24439. * @param name defines the name of the mesh
  24440. * @param options defines the options used to create the mesh
  24441. * @param scene defines the hosting scene
  24442. * @returns the polygon mesh
  24443. */
  24444. static CreatePolygon(name: string, options: {
  24445. shape: Vector3[];
  24446. holes?: Vector3[][];
  24447. depth?: number;
  24448. faceUV?: Vector4[];
  24449. faceColors?: Color4[];
  24450. updatable?: boolean;
  24451. sideOrientation?: number;
  24452. frontUVs?: Vector4;
  24453. backUVs?: Vector4;
  24454. }, scene: Scene): Mesh;
  24455. /**
  24456. * Creates an extruded polygon mesh, with depth in the Y direction.
  24457. * * 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)
  24458. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  24459. * @param name defines the name of the mesh
  24460. * @param options defines the options used to create the mesh
  24461. * @param scene defines the hosting scene
  24462. * @returns the polygon mesh
  24463. */
  24464. static ExtrudePolygon(name: string, options: {
  24465. shape: Vector3[];
  24466. holes?: Vector3[][];
  24467. depth?: number;
  24468. faceUV?: Vector4[];
  24469. faceColors?: Color4[];
  24470. updatable?: boolean;
  24471. sideOrientation?: number;
  24472. frontUVs?: Vector4;
  24473. backUVs?: Vector4;
  24474. }, scene: Scene): Mesh;
  24475. /**
  24476. * Creates a tube mesh.
  24477. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  24478. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  24479. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  24480. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  24481. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  24482. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  24483. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  24484. * * 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
  24485. * * 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
  24486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24490. * @param name defines the name of the mesh
  24491. * @param options defines the options used to create the mesh
  24492. * @param scene defines the hosting scene
  24493. * @returns the tube mesh
  24494. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  24495. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  24496. */
  24497. static CreateTube(name: string, options: {
  24498. path: Vector3[];
  24499. radius?: number;
  24500. tessellation?: number;
  24501. radiusFunction?: {
  24502. (i: number, distance: number): number;
  24503. };
  24504. cap?: number;
  24505. arc?: number;
  24506. updatable?: boolean;
  24507. sideOrientation?: number;
  24508. frontUVs?: Vector4;
  24509. backUVs?: Vector4;
  24510. instance?: Mesh;
  24511. invertUV?: boolean;
  24512. }, scene: Scene): Mesh;
  24513. /**
  24514. * Creates a polyhedron mesh
  24515. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  24516. * * The parameter `size` (positive float, default 1) sets the polygon size
  24517. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24518. * * 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`
  24519. * * 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
  24520. * * 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)`)
  24521. * * 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
  24522. * * 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
  24523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24526. * @param name defines the name of the mesh
  24527. * @param options defines the options used to create the mesh
  24528. * @param scene defines the hosting scene
  24529. * @returns the polyhedron mesh
  24530. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  24531. */
  24532. static CreatePolyhedron(name: string, options: {
  24533. type?: number;
  24534. size?: number;
  24535. sizeX?: number;
  24536. sizeY?: number;
  24537. sizeZ?: number;
  24538. custom?: any;
  24539. faceUV?: Vector4[];
  24540. faceColors?: Color4[];
  24541. flat?: boolean;
  24542. updatable?: boolean;
  24543. sideOrientation?: number;
  24544. frontUVs?: Vector4;
  24545. backUVs?: Vector4;
  24546. }, scene: Scene): Mesh;
  24547. /**
  24548. * Creates a decal mesh.
  24549. * 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
  24550. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  24551. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  24552. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  24553. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  24554. * @param name defines the name of the mesh
  24555. * @param sourceMesh defines the mesh where the decal must be applied
  24556. * @param options defines the options used to create the mesh
  24557. * @param scene defines the hosting scene
  24558. * @returns the decal mesh
  24559. * @see http://doc.babylonjs.com/how_to/decals
  24560. */
  24561. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  24562. position?: Vector3;
  24563. normal?: Vector3;
  24564. size?: Vector3;
  24565. angle?: number;
  24566. }): Mesh;
  24567. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  24568. }
  24569. }
  24570. declare module BABYLON {
  24571. class MeshLODLevel {
  24572. distance: number;
  24573. mesh: Mesh;
  24574. constructor(distance: number, mesh: Mesh);
  24575. }
  24576. }
  24577. declare module BABYLON {
  24578. /**
  24579. * A simplifier interface for future simplification implementations.
  24580. */
  24581. interface ISimplifier {
  24582. /**
  24583. * Simplification of a given mesh according to the given settings.
  24584. * Since this requires computation, it is assumed that the function runs async.
  24585. * @param settings The settings of the simplification, including quality and distance
  24586. * @param successCallback A callback that will be called after the mesh was simplified.
  24587. * @param errorCallback in case of an error, this callback will be called. optional.
  24588. */
  24589. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  24590. }
  24591. /**
  24592. * Expected simplification settings.
  24593. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  24594. */
  24595. interface ISimplificationSettings {
  24596. quality: number;
  24597. distance: number;
  24598. optimizeMesh?: boolean;
  24599. }
  24600. class SimplificationSettings implements ISimplificationSettings {
  24601. quality: number;
  24602. distance: number;
  24603. optimizeMesh: boolean | undefined;
  24604. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  24605. }
  24606. interface ISimplificationTask {
  24607. settings: Array<ISimplificationSettings>;
  24608. simplificationType: SimplificationType;
  24609. mesh: Mesh;
  24610. successCallback?: () => void;
  24611. parallelProcessing: boolean;
  24612. }
  24613. class SimplificationQueue {
  24614. private _simplificationArray;
  24615. running: boolean;
  24616. constructor();
  24617. addTask(task: ISimplificationTask): void;
  24618. executeNext(): void;
  24619. runSimplification(task: ISimplificationTask): void;
  24620. private getSimplifier(task);
  24621. }
  24622. /**
  24623. * The implemented types of simplification
  24624. * At the moment only Quadratic Error Decimation is implemented
  24625. */
  24626. enum SimplificationType {
  24627. /** Quadratic error decimation */
  24628. QUADRATIC = 0,
  24629. }
  24630. class DecimationTriangle {
  24631. vertices: Array<DecimationVertex>;
  24632. normal: Vector3;
  24633. error: Array<number>;
  24634. deleted: boolean;
  24635. isDirty: boolean;
  24636. borderFactor: number;
  24637. deletePending: boolean;
  24638. originalOffset: number;
  24639. constructor(vertices: Array<DecimationVertex>);
  24640. }
  24641. class DecimationVertex {
  24642. position: Vector3;
  24643. id: number;
  24644. q: QuadraticMatrix;
  24645. isBorder: boolean;
  24646. triangleStart: number;
  24647. triangleCount: number;
  24648. originalOffsets: Array<number>;
  24649. constructor(position: Vector3, id: number);
  24650. updatePosition(newPosition: Vector3): void;
  24651. }
  24652. class QuadraticMatrix {
  24653. data: Array<number>;
  24654. constructor(data?: Array<number>);
  24655. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  24656. addInPlace(matrix: QuadraticMatrix): void;
  24657. addArrayInPlace(data: Array<number>): void;
  24658. add(matrix: QuadraticMatrix): QuadraticMatrix;
  24659. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  24660. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  24661. }
  24662. class Reference {
  24663. vertexId: number;
  24664. triangleId: number;
  24665. constructor(vertexId: number, triangleId: number);
  24666. }
  24667. /**
  24668. * An implementation of the Quadratic Error simplification algorithm.
  24669. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  24670. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  24671. * @author RaananW
  24672. */
  24673. class QuadraticErrorSimplification implements ISimplifier {
  24674. private _mesh;
  24675. private triangles;
  24676. private vertices;
  24677. private references;
  24678. private _reconstructedMesh;
  24679. syncIterations: number;
  24680. aggressiveness: number;
  24681. decimationIterations: number;
  24682. boundingBoxEpsilon: number;
  24683. constructor(_mesh: Mesh);
  24684. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  24685. private runDecimation(settings, submeshIndex, successCallback);
  24686. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  24687. private init(callback);
  24688. private reconstructMesh(submeshIndex);
  24689. private initDecimatedMesh();
  24690. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  24691. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  24692. private identifyBorder();
  24693. private updateMesh(identifyBorders?);
  24694. private vertexError(q, point);
  24695. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  24696. }
  24697. }
  24698. declare module BABYLON {
  24699. class Polygon {
  24700. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  24701. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  24702. static Parse(input: string): Vector2[];
  24703. static StartingAt(x: number, y: number): Path2;
  24704. }
  24705. class PolygonMeshBuilder {
  24706. private _points;
  24707. private _outlinepoints;
  24708. private _holes;
  24709. private _name;
  24710. private _scene;
  24711. private _epoints;
  24712. private _eholes;
  24713. private _addToepoint(points);
  24714. constructor(name: string, contours: Path2, scene: Scene);
  24715. constructor(name: string, contours: Vector2[], scene: Scene);
  24716. addHole(hole: Vector2[]): PolygonMeshBuilder;
  24717. build(updatable?: boolean, depth?: number): Mesh;
  24718. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  24719. }
  24720. }
  24721. declare module BABYLON {
  24722. class BaseSubMesh {
  24723. _materialDefines: Nullable<MaterialDefines>;
  24724. _materialEffect: Nullable<Effect>;
  24725. readonly effect: Nullable<Effect>;
  24726. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24727. }
  24728. class SubMesh extends BaseSubMesh implements ICullable {
  24729. materialIndex: number;
  24730. verticesStart: number;
  24731. verticesCount: number;
  24732. indexStart: number;
  24733. indexCount: number;
  24734. linesIndexCount: number;
  24735. private _mesh;
  24736. private _renderingMesh;
  24737. private _boundingInfo;
  24738. private _linesIndexBuffer;
  24739. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24740. _trianglePlanes: Plane[];
  24741. _lastColliderTransformMatrix: Matrix;
  24742. _renderId: number;
  24743. _alphaIndex: number;
  24744. _distanceToCamera: number;
  24745. _id: number;
  24746. private _currentMaterial;
  24747. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24748. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24749. readonly IsGlobal: boolean;
  24750. /**
  24751. * Returns the submesh BoudingInfo object.
  24752. */
  24753. getBoundingInfo(): BoundingInfo;
  24754. /**
  24755. * Sets the submesh BoundingInfo.
  24756. * Return the SubMesh.
  24757. */
  24758. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24759. /**
  24760. * Returns the mesh of the current submesh.
  24761. */
  24762. getMesh(): AbstractMesh;
  24763. /**
  24764. * Returns the rendering mesh of the submesh.
  24765. */
  24766. getRenderingMesh(): Mesh;
  24767. /**
  24768. * Returns the submesh material.
  24769. */
  24770. getMaterial(): Nullable<Material>;
  24771. /**
  24772. * Sets a new updated BoundingInfo object to the submesh.
  24773. * Returns the SubMesh.
  24774. */
  24775. refreshBoundingInfo(): SubMesh;
  24776. _checkCollision(collider: Collider): boolean;
  24777. /**
  24778. * Updates the submesh BoundingInfo.
  24779. * Returns the Submesh.
  24780. */
  24781. updateBoundingInfo(world: Matrix): SubMesh;
  24782. /**
  24783. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24784. * Boolean returned.
  24785. */
  24786. isInFrustum(frustumPlanes: Plane[]): boolean;
  24787. /**
  24788. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  24789. * Boolean returned.
  24790. */
  24791. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24792. /**
  24793. * Renders the submesh.
  24794. * Returns it.
  24795. */
  24796. render(enableAlphaMode: boolean): SubMesh;
  24797. /**
  24798. * Returns a new Index Buffer.
  24799. * Type returned : WebGLBuffer.
  24800. */
  24801. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  24802. /**
  24803. * True is the passed Ray intersects the submesh bounding box.
  24804. * Boolean returned.
  24805. */
  24806. canIntersects(ray: Ray): boolean;
  24807. /**
  24808. * Returns an object IntersectionInfo.
  24809. */
  24810. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  24811. _rebuild(): void;
  24812. /**
  24813. * Creates a new Submesh from the passed Mesh.
  24814. */
  24815. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24816. /**
  24817. * Disposes the Submesh.
  24818. * Returns nothing.
  24819. */
  24820. dispose(): void;
  24821. /**
  24822. * Creates a new Submesh from the passed parameters :
  24823. * - materialIndex (integer) : the index of the main mesh material.
  24824. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  24825. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  24826. * - mesh (Mesh) : the main mesh to create the submesh from.
  24827. * - renderingMesh (optional Mesh) : rendering mesh.
  24828. */
  24829. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24830. }
  24831. }
  24832. declare module BABYLON {
  24833. class TransformNode extends Node {
  24834. static BILLBOARDMODE_NONE: number;
  24835. static BILLBOARDMODE_X: number;
  24836. static BILLBOARDMODE_Y: number;
  24837. static BILLBOARDMODE_Z: number;
  24838. static BILLBOARDMODE_ALL: number;
  24839. private _forward;
  24840. private _forwardInverted;
  24841. private _up;
  24842. private _right;
  24843. private _rightInverted;
  24844. private _rotation;
  24845. private _rotationQuaternion;
  24846. protected _scaling: Vector3;
  24847. protected _isDirty: boolean;
  24848. private _transformToBoneReferal;
  24849. billboardMode: number;
  24850. scalingDeterminant: number;
  24851. infiniteDistance: boolean;
  24852. /**
  24853. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  24854. * By default the system will update normals to compensate
  24855. */
  24856. ignoreNonUniformScaling: boolean;
  24857. position: Vector3;
  24858. _poseMatrix: Matrix;
  24859. private _localWorld;
  24860. _worldMatrix: Matrix;
  24861. _worldMatrixDeterminant: number;
  24862. private _absolutePosition;
  24863. private _pivotMatrix;
  24864. private _pivotMatrixInverse;
  24865. private _postMultiplyPivotMatrix;
  24866. protected _isWorldMatrixFrozen: boolean;
  24867. /**
  24868. * An event triggered after the world matrix is updated
  24869. */
  24870. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  24871. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  24872. /**
  24873. * Gets a string idenfifying the name of the class
  24874. * @returns "TransformNode" string
  24875. */
  24876. getClassName(): string;
  24877. /**
  24878. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  24879. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  24880. * Default : (0.0, 0.0, 0.0)
  24881. */
  24882. rotation: Vector3;
  24883. /**
  24884. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24885. * Default : (1.0, 1.0, 1.0)
  24886. */
  24887. /**
  24888. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24889. * Default : (1.0, 1.0, 1.0)
  24890. */
  24891. scaling: Vector3;
  24892. /**
  24893. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  24894. * It's null by default.
  24895. * 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)
  24896. */
  24897. rotationQuaternion: Nullable<Quaternion>;
  24898. /**
  24899. * The forward direction of that transform in world space.
  24900. */
  24901. readonly forward: Vector3;
  24902. /**
  24903. * The up direction of that transform in world space.
  24904. */
  24905. readonly up: Vector3;
  24906. /**
  24907. * The right direction of that transform in world space.
  24908. */
  24909. readonly right: Vector3;
  24910. /**
  24911. * Returns the latest update of the World matrix
  24912. * Returns a Matrix.
  24913. */
  24914. getWorldMatrix(): Matrix;
  24915. /** @hidden */
  24916. _getWorldMatrixDeterminant(): number;
  24917. /**
  24918. * Returns directly the latest state of the mesh World matrix.
  24919. * A Matrix is returned.
  24920. */
  24921. readonly worldMatrixFromCache: Matrix;
  24922. /**
  24923. * Copies the paramater passed Matrix into the mesh Pose matrix.
  24924. * Returns the TransformNode.
  24925. */
  24926. updatePoseMatrix(matrix: Matrix): TransformNode;
  24927. /**
  24928. * Returns the mesh Pose matrix.
  24929. * Returned object : Matrix
  24930. */
  24931. getPoseMatrix(): Matrix;
  24932. _isSynchronized(): boolean;
  24933. _initCache(): void;
  24934. markAsDirty(property: string): TransformNode;
  24935. /**
  24936. * Returns the current mesh absolute position.
  24937. * Retuns a Vector3.
  24938. */
  24939. readonly absolutePosition: Vector3;
  24940. /**
  24941. * Sets a new matrix to apply before all other transformation
  24942. * @param matrix defines the transform matrix
  24943. * @returns the current TransformNode
  24944. */
  24945. setPreTransformMatrix(matrix: Matrix): TransformNode;
  24946. /**
  24947. * Sets a new pivot matrix to the current node
  24948. * @param matrix defines the new pivot matrix to use
  24949. * @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
  24950. * @returns the current TransformNode
  24951. */
  24952. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  24953. /**
  24954. * Returns the mesh pivot matrix.
  24955. * Default : Identity.
  24956. * A Matrix is returned.
  24957. */
  24958. getPivotMatrix(): Matrix;
  24959. /**
  24960. * Prevents the World matrix to be computed any longer.
  24961. * Returns the TransformNode.
  24962. */
  24963. freezeWorldMatrix(): TransformNode;
  24964. /**
  24965. * Allows back the World matrix computation.
  24966. * Returns the TransformNode.
  24967. */
  24968. unfreezeWorldMatrix(): this;
  24969. /**
  24970. * True if the World matrix has been frozen.
  24971. * Returns a boolean.
  24972. */
  24973. readonly isWorldMatrixFrozen: boolean;
  24974. /**
  24975. * Retuns the mesh absolute position in the World.
  24976. * Returns a Vector3.
  24977. */
  24978. getAbsolutePosition(): Vector3;
  24979. /**
  24980. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  24981. * Returns the TransformNode.
  24982. */
  24983. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24984. /**
  24985. * Sets the mesh position in its local space.
  24986. * Returns the TransformNode.
  24987. */
  24988. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  24989. /**
  24990. * Returns the mesh position in the local space from the current World matrix values.
  24991. * Returns a new Vector3.
  24992. */
  24993. getPositionExpressedInLocalSpace(): Vector3;
  24994. /**
  24995. * Translates the mesh along the passed Vector3 in its local space.
  24996. * Returns the TransformNode.
  24997. */
  24998. locallyTranslate(vector3: Vector3): TransformNode;
  24999. private static _lookAtVectorCache;
  25000. /**
  25001. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  25002. * @param targetPoint the position (must be in same space as current mesh) to look at
  25003. * @param yawCor optional yaw (y-axis) correction in radians
  25004. * @param pitchCor optional pitch (x-axis) correction in radians
  25005. * @param rollCor optional roll (z-axis) correction in radians
  25006. * @param space the choosen space of the target
  25007. * @returns the TransformNode.
  25008. */
  25009. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  25010. /**
  25011. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  25012. * This Vector3 is expressed in the World space.
  25013. */
  25014. getDirection(localAxis: Vector3): Vector3;
  25015. /**
  25016. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  25017. * localAxis is expressed in the mesh local space.
  25018. * result is computed in the Wordl space from the mesh World matrix.
  25019. * Returns the TransformNode.
  25020. */
  25021. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  25022. /**
  25023. * Sets a new pivot point to the current node
  25024. * @param point defines the new pivot point to use
  25025. * @param space defines if the point is in world or local space (local by default)
  25026. * @returns the current TransformNode
  25027. */
  25028. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  25029. /**
  25030. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  25031. */
  25032. getPivotPoint(): Vector3;
  25033. /**
  25034. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  25035. * Returns the TransformNode.
  25036. */
  25037. getPivotPointToRef(result: Vector3): TransformNode;
  25038. /**
  25039. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  25040. */
  25041. getAbsolutePivotPoint(): Vector3;
  25042. /**
  25043. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  25044. * Returns the TransformNode.
  25045. */
  25046. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  25047. /**
  25048. * Defines the passed node as the parent of the current node.
  25049. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  25050. * Returns the TransformNode.
  25051. */
  25052. setParent(node: Nullable<Node>): TransformNode;
  25053. private _nonUniformScaling;
  25054. readonly nonUniformScaling: boolean;
  25055. _updateNonUniformScalingState(value: boolean): boolean;
  25056. /**
  25057. * Attach the current TransformNode to another TransformNode associated with a bone
  25058. * @param bone Bone affecting the TransformNode
  25059. * @param affectedTransformNode TransformNode associated with the bone
  25060. */
  25061. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  25062. detachFromBone(): TransformNode;
  25063. private static _rotationAxisCache;
  25064. /**
  25065. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  25066. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  25067. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  25068. * The passed axis is also normalized.
  25069. * Returns the TransformNode.
  25070. */
  25071. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  25072. /**
  25073. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  25074. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  25075. * The passed axis is also normalized.
  25076. * Returns the TransformNode.
  25077. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  25078. */
  25079. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  25080. /**
  25081. * Translates the mesh along the axis vector for the passed distance in the given space.
  25082. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  25083. * Returns the TransformNode.
  25084. */
  25085. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  25086. /**
  25087. * Adds a rotation step to the mesh current rotation.
  25088. * x, y, z are Euler angles expressed in radians.
  25089. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  25090. * This means this rotation is made in the mesh local space only.
  25091. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  25092. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  25093. * ```javascript
  25094. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  25095. * ```
  25096. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  25097. * 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.
  25098. * Returns the TransformNode.
  25099. */
  25100. addRotation(x: number, y: number, z: number): TransformNode;
  25101. /**
  25102. * Computes the mesh World matrix and returns it.
  25103. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  25104. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  25105. * If the parameter `force`is set to `true`, the actual computation is done.
  25106. * Returns the mesh World Matrix.
  25107. */
  25108. computeWorldMatrix(force?: boolean): Matrix;
  25109. protected _afterComputeWorldMatrix(): void;
  25110. /**
  25111. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  25112. * @param func: callback function to add
  25113. *
  25114. * Returns the TransformNode.
  25115. */
  25116. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  25117. /**
  25118. * Removes a registered callback function.
  25119. * Returns the TransformNode.
  25120. */
  25121. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  25122. /**
  25123. * Clone the current transform node
  25124. * Returns the new transform node
  25125. * @param name Name of the new clone
  25126. * @param newParent New parent for the clone
  25127. * @param doNotCloneChildren Do not clone children hierarchy
  25128. */
  25129. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  25130. serialize(currentSerializationObject?: any): any;
  25131. /**
  25132. * Returns a new TransformNode object parsed from the source provided.
  25133. * The parameter `parsedMesh` is the source.
  25134. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  25135. */
  25136. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  25137. /**
  25138. * Releases resources associated with this transform node.
  25139. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25140. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25141. */
  25142. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25143. }
  25144. }
  25145. declare module BABYLON {
  25146. class VertexBuffer {
  25147. /** @hidden */
  25148. _buffer: Buffer;
  25149. private _kind;
  25150. private _size;
  25151. private _ownsBuffer;
  25152. private _instanced;
  25153. private _instanceDivisor;
  25154. /**
  25155. * The byte type.
  25156. */
  25157. static readonly BYTE: number;
  25158. /**
  25159. * The unsigned byte type.
  25160. */
  25161. static readonly UNSIGNED_BYTE: number;
  25162. /**
  25163. * The short type.
  25164. */
  25165. static readonly SHORT: number;
  25166. /**
  25167. * The unsigned short type.
  25168. */
  25169. static readonly UNSIGNED_SHORT: number;
  25170. /**
  25171. * The integer type.
  25172. */
  25173. static readonly INT: number;
  25174. /**
  25175. * The unsigned integer type.
  25176. */
  25177. static readonly UNSIGNED_INT: number;
  25178. /**
  25179. * The float type.
  25180. */
  25181. static readonly FLOAT: number;
  25182. /**
  25183. * Gets or sets the instance divisor when in instanced mode
  25184. */
  25185. instanceDivisor: number;
  25186. /**
  25187. * Gets the byte stride.
  25188. */
  25189. readonly byteStride: number;
  25190. /**
  25191. * Gets the byte offset.
  25192. */
  25193. readonly byteOffset: number;
  25194. /**
  25195. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  25196. */
  25197. readonly normalized: boolean;
  25198. /**
  25199. * Gets the data type of each component in the array.
  25200. */
  25201. readonly type: number;
  25202. /**
  25203. * Constructor
  25204. * @param engine the engine
  25205. * @param data the data to use for this vertex buffer
  25206. * @param kind the vertex buffer kind
  25207. * @param updatable whether the data is updatable
  25208. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25209. * @param stride the stride (optional)
  25210. * @param instanced whether the buffer is instanced (optional)
  25211. * @param offset the offset of the data (optional)
  25212. * @param size the number of components (optional)
  25213. * @param type the type of the component (optional)
  25214. * @param normalized whether the data contains normalized data (optional)
  25215. * @param useBytes set to true if stride and offset are in bytes (optional)
  25216. */
  25217. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  25218. _rebuild(): void;
  25219. /**
  25220. * Returns the kind of the VertexBuffer (string).
  25221. */
  25222. getKind(): string;
  25223. /**
  25224. * Boolean : is the VertexBuffer updatable ?
  25225. */
  25226. isUpdatable(): boolean;
  25227. /**
  25228. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  25229. */
  25230. getData(): Nullable<DataArray>;
  25231. /**
  25232. * Returns the WebGLBuffer associated to the VertexBuffer.
  25233. */
  25234. getBuffer(): Nullable<WebGLBuffer>;
  25235. /**
  25236. * Returns the stride as a multiple of the type byte length.
  25237. * DEPRECATED. Use byteStride instead.
  25238. */
  25239. getStrideSize(): number;
  25240. /**
  25241. * Returns the offset as a multiple of the type byte length.
  25242. * DEPRECATED. Use byteOffset instead.
  25243. */
  25244. getOffset(): number;
  25245. /**
  25246. * Returns the number of components per vertex attribute (integer).
  25247. */
  25248. getSize(): number;
  25249. /**
  25250. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  25251. */
  25252. getIsInstanced(): boolean;
  25253. /**
  25254. * Returns the instancing divisor, zero for non-instanced (integer).
  25255. */
  25256. getInstanceDivisor(): number;
  25257. /**
  25258. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  25259. * Returns the created WebGLBuffer.
  25260. */
  25261. create(data?: DataArray): void;
  25262. /**
  25263. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  25264. * This function will create a new buffer if the current one is not updatable
  25265. * Returns the updated WebGLBuffer.
  25266. */
  25267. update(data: DataArray): void;
  25268. /**
  25269. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  25270. * Returns the directly updated WebGLBuffer.
  25271. * @param data the new data
  25272. * @param offset the new offset
  25273. * @param useBytes set to true if the offset is in bytes
  25274. */
  25275. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  25276. /**
  25277. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  25278. */
  25279. dispose(): void;
  25280. /**
  25281. * Enumerates each value of this vertex buffer as numbers.
  25282. * @param count the number of values to enumerate
  25283. * @param callback the callback function called for each value
  25284. */
  25285. forEach(count: number, callback: (value: number, index: number) => void): void;
  25286. private static _PositionKind;
  25287. private static _NormalKind;
  25288. private static _TangentKind;
  25289. private static _UVKind;
  25290. private static _UV2Kind;
  25291. private static _UV3Kind;
  25292. private static _UV4Kind;
  25293. private static _UV5Kind;
  25294. private static _UV6Kind;
  25295. private static _ColorKind;
  25296. private static _MatricesIndicesKind;
  25297. private static _MatricesWeightsKind;
  25298. private static _MatricesIndicesExtraKind;
  25299. private static _MatricesWeightsExtraKind;
  25300. static readonly PositionKind: string;
  25301. static readonly NormalKind: string;
  25302. static readonly TangentKind: string;
  25303. static readonly UVKind: string;
  25304. static readonly UV2Kind: string;
  25305. static readonly UV3Kind: string;
  25306. static readonly UV4Kind: string;
  25307. static readonly UV5Kind: string;
  25308. static readonly UV6Kind: string;
  25309. static readonly ColorKind: string;
  25310. static readonly MatricesIndicesKind: string;
  25311. static readonly MatricesWeightsKind: string;
  25312. static readonly MatricesIndicesExtraKind: string;
  25313. static readonly MatricesWeightsExtraKind: string;
  25314. /**
  25315. * Deduces the stride given a kind.
  25316. * @param kind The kind string to deduce
  25317. * @returns The deduced stride
  25318. */
  25319. static DeduceStride(kind: string): number;
  25320. /**
  25321. * Gets the byte length of the given type.
  25322. * @param type the type
  25323. * @returns the number of bytes
  25324. */
  25325. static GetTypeByteLength(type: number): number;
  25326. /**
  25327. * Enumerates each value of the given parameters as numbers.
  25328. * @param data the data to enumerate
  25329. * @param byteOffset the byte offset of the data
  25330. * @param byteStride the byte stride of the data
  25331. * @param componentCount the number of components per element
  25332. * @param componentType the type of the component
  25333. * @param count the total number of components
  25334. * @param normalized whether the data is normalized
  25335. * @param callback the callback function called for each value
  25336. */
  25337. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  25338. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  25339. }
  25340. }
  25341. declare module BABYLON {
  25342. class ReflectionProbe {
  25343. name: string;
  25344. private _scene;
  25345. private _renderTargetTexture;
  25346. private _projectionMatrix;
  25347. private _viewMatrix;
  25348. private _target;
  25349. private _add;
  25350. private _attachedMesh;
  25351. private _invertYAxis;
  25352. position: Vector3;
  25353. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  25354. samples: number;
  25355. refreshRate: number;
  25356. getScene(): Scene;
  25357. readonly cubeTexture: RenderTargetTexture;
  25358. readonly renderList: Nullable<AbstractMesh[]>;
  25359. attachToMesh(mesh: AbstractMesh): void;
  25360. /**
  25361. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25362. *
  25363. * @param renderingGroupId The rendering group id corresponding to its index
  25364. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25365. */
  25366. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25367. dispose(): void;
  25368. }
  25369. }
  25370. declare module BABYLON {
  25371. /**
  25372. * Postprocess used to generate anaglyphic rendering
  25373. */
  25374. class AnaglyphPostProcess extends PostProcess {
  25375. private _passedProcess;
  25376. /**
  25377. * Creates a new AnaglyphPostProcess
  25378. * @param name defines postprocess name
  25379. * @param options defines creation options or target ratio scale
  25380. * @param rigCameras defines cameras using this postprocess
  25381. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25382. * @param engine defines hosting engine
  25383. * @param reusable defines if the postprocess will be reused multiple times per frame
  25384. */
  25385. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25386. }
  25387. }
  25388. declare module BABYLON {
  25389. class BlackAndWhitePostProcess extends PostProcess {
  25390. degree: number;
  25391. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25392. }
  25393. }
  25394. declare module BABYLON {
  25395. /**
  25396. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25397. */
  25398. class BloomEffect extends PostProcessRenderEffect {
  25399. private bloomScale;
  25400. /**
  25401. * Internal
  25402. */
  25403. _effects: Array<PostProcess>;
  25404. /**
  25405. * Internal
  25406. */
  25407. _downscale: ExtractHighlightsPostProcess;
  25408. private _blurX;
  25409. private _blurY;
  25410. private _merge;
  25411. /**
  25412. * The luminance threshold to find bright areas of the image to bloom.
  25413. */
  25414. threshold: number;
  25415. /**
  25416. * The strength of the bloom.
  25417. */
  25418. weight: number;
  25419. /**
  25420. * Specifies the size of the bloom blur kernel, relative to the final output size
  25421. */
  25422. kernel: number;
  25423. /**
  25424. * Creates a new instance of @see BloomEffect
  25425. * @param scene The scene the effect belongs to.
  25426. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25427. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25428. * @param bloomWeight The the strength of bloom.
  25429. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25430. * @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)
  25431. */
  25432. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25433. /**
  25434. * Disposes each of the internal effects for a given camera.
  25435. * @param camera The camera to dispose the effect on.
  25436. */
  25437. disposeEffects(camera: Camera): void;
  25438. /**
  25439. * Internal
  25440. */
  25441. _updateEffects(): void;
  25442. /**
  25443. * Internal
  25444. * @returns if all the contained post processes are ready.
  25445. */
  25446. _isReady(): boolean;
  25447. }
  25448. }
  25449. declare module BABYLON {
  25450. /**
  25451. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25452. */
  25453. class BloomMergePostProcess extends PostProcess {
  25454. /** Weight of the bloom to be added to the original input. */ weight: number;
  25455. /**
  25456. * Creates a new instance of @see BloomMergePostProcess
  25457. * @param name The name of the effect.
  25458. * @param originalFromInput Post process which's input will be used for the merge.
  25459. * @param blurred Blurred highlights post process which's output will be used.
  25460. * @param weight Weight of the bloom to be added to the original input.
  25461. * @param options The required width/height ratio to downsize to before computing the render pass.
  25462. * @param camera The camera to apply the render pass to.
  25463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25464. * @param engine The engine which the post process will be applied. (default: current engine)
  25465. * @param reusable If the post process can be reused on the same frame. (default: false)
  25466. * @param textureType Type of textures used when performing the post process. (default: 0)
  25467. * @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)
  25468. */
  25469. 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);
  25470. }
  25471. }
  25472. declare module BABYLON {
  25473. /**
  25474. * The Blur Post Process which blurs an image based on a kernel and direction.
  25475. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25476. */
  25477. class BlurPostProcess extends PostProcess {
  25478. /** The direction in which to blur the image. */ direction: Vector2;
  25479. private blockCompilation;
  25480. protected _kernel: number;
  25481. protected _idealKernel: number;
  25482. protected _packedFloat: boolean;
  25483. private _staticDefines;
  25484. /**
  25485. * Gets the length in pixels of the blur sample region
  25486. */
  25487. /**
  25488. * Sets the length in pixels of the blur sample region
  25489. */
  25490. kernel: number;
  25491. /**
  25492. * Gets wether or not the blur is unpacking/repacking floats
  25493. */
  25494. /**
  25495. * Sets wether or not the blur needs to unpack/repack floats
  25496. */
  25497. packedFloat: boolean;
  25498. /**
  25499. * Creates a new instance BlurPostProcess
  25500. * @param name The name of the effect.
  25501. * @param direction The direction in which to blur the image.
  25502. * @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.
  25503. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25504. * @param camera The camera to apply the render pass to.
  25505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25506. * @param engine The engine which the post process will be applied. (default: current engine)
  25507. * @param reusable If the post process can be reused on the same frame. (default: false)
  25508. * @param textureType Type of textures used when performing the post process. (default: 0)
  25509. * @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)
  25510. */
  25511. 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);
  25512. /**
  25513. * Updates the effect with the current post process compile time values and recompiles the shader.
  25514. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25515. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25516. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25517. * @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
  25518. * @param onCompiled Called when the shader has been compiled.
  25519. * @param onError Called if there is an error when compiling a shader.
  25520. */
  25521. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25522. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25523. /**
  25524. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25525. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25526. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25527. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25528. * The gaps between physical kernels are compensated for in the weighting of the samples
  25529. * @param idealKernel Ideal blur kernel.
  25530. * @return Nearest best kernel.
  25531. */
  25532. protected _nearestBestKernel(idealKernel: number): number;
  25533. /**
  25534. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25535. * @param x The point on the Gaussian distribution to sample.
  25536. * @return the value of the Gaussian function at x.
  25537. */
  25538. protected _gaussianWeight(x: number): number;
  25539. /**
  25540. * Generates a string that can be used as a floating point number in GLSL.
  25541. * @param x Value to print.
  25542. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25543. * @return GLSL float string.
  25544. */
  25545. protected _glslFloat(x: number, decimalFigures?: number): string;
  25546. }
  25547. }
  25548. declare module BABYLON {
  25549. /**
  25550. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25551. */
  25552. class ChromaticAberrationPostProcess extends PostProcess {
  25553. /**
  25554. * The amount of seperation of rgb channels (default: 30)
  25555. */
  25556. aberrationAmount: number;
  25557. /**
  25558. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25559. */
  25560. radialIntensity: number;
  25561. /**
  25562. * 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))
  25563. */
  25564. direction: Vector2;
  25565. /**
  25566. * 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))
  25567. */
  25568. centerPosition: Vector2;
  25569. /**
  25570. * Creates a new instance ChromaticAberrationPostProcess
  25571. * @param name The name of the effect.
  25572. * @param screenWidth The width of the screen to apply the effect on.
  25573. * @param screenHeight The height of the screen to apply the effect on.
  25574. * @param options The required width/height ratio to downsize to before computing the render pass.
  25575. * @param camera The camera to apply the render pass to.
  25576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25577. * @param engine The engine which the post process will be applied. (default: current engine)
  25578. * @param reusable If the post process can be reused on the same frame. (default: false)
  25579. * @param textureType Type of textures used when performing the post process. (default: 0)
  25580. * @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)
  25581. */
  25582. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25583. }
  25584. }
  25585. declare module BABYLON {
  25586. /**
  25587. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25588. */
  25589. class CircleOfConfusionPostProcess extends PostProcess {
  25590. /**
  25591. * 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.
  25592. */
  25593. lensSize: number;
  25594. /**
  25595. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25596. */
  25597. fStop: number;
  25598. /**
  25599. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25600. */
  25601. focusDistance: number;
  25602. /**
  25603. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25604. */
  25605. focalLength: number;
  25606. private _depthTexture;
  25607. /**
  25608. * Creates a new instance CircleOfConfusionPostProcess
  25609. * @param name The name of the effect.
  25610. * @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.
  25611. * @param options The required width/height ratio to downsize to before computing the render pass.
  25612. * @param camera The camera to apply the render pass to.
  25613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25614. * @param engine The engine which the post process will be applied. (default: current engine)
  25615. * @param reusable If the post process can be reused on the same frame. (default: false)
  25616. * @param textureType Type of textures used when performing the post process. (default: 0)
  25617. * @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)
  25618. */
  25619. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25620. /**
  25621. * 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.
  25622. */
  25623. depthTexture: RenderTargetTexture;
  25624. }
  25625. }
  25626. declare module BABYLON {
  25627. class ColorCorrectionPostProcess extends PostProcess {
  25628. private _colorTableTexture;
  25629. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25630. }
  25631. }
  25632. declare module BABYLON {
  25633. /**
  25634. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25635. * input texture to perform effects such as edge detection or sharpening
  25636. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25637. */
  25638. class ConvolutionPostProcess extends PostProcess {
  25639. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25640. /**
  25641. * Creates a new instance ConvolutionPostProcess
  25642. * @param name The name of the effect.
  25643. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25644. * @param options The required width/height ratio to downsize to before computing the render pass.
  25645. * @param camera The camera to apply the render pass to.
  25646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25647. * @param engine The engine which the post process will be applied. (default: current engine)
  25648. * @param reusable If the post process can be reused on the same frame. (default: false)
  25649. * @param textureType Type of textures used when performing the post process. (default: 0)
  25650. */
  25651. 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);
  25652. /**
  25653. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25654. */
  25655. static EdgeDetect0Kernel: number[];
  25656. /**
  25657. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25658. */
  25659. static EdgeDetect1Kernel: number[];
  25660. /**
  25661. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25662. */
  25663. static EdgeDetect2Kernel: number[];
  25664. /**
  25665. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25666. */
  25667. static SharpenKernel: number[];
  25668. /**
  25669. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25670. */
  25671. static EmbossKernel: number[];
  25672. /**
  25673. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25674. */
  25675. static GaussianKernel: number[];
  25676. }
  25677. }
  25678. declare module BABYLON {
  25679. /**
  25680. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25681. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25682. * based on samples that have a large difference in distance than the center pixel.
  25683. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25684. */
  25685. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25686. direction: Vector2;
  25687. /**
  25688. * Creates a new instance CircleOfConfusionPostProcess
  25689. * @param name The name of the effect.
  25690. * @param scene The scene the effect belongs to.
  25691. * @param direction The direction the blur should be applied.
  25692. * @param kernel The size of the kernel used to blur.
  25693. * @param options The required width/height ratio to downsize to before computing the render pass.
  25694. * @param camera The camera to apply the render pass to.
  25695. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25696. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25698. * @param engine The engine which the post process will be applied. (default: current engine)
  25699. * @param reusable If the post process can be reused on the same frame. (default: false)
  25700. * @param textureType Type of textures used when performing the post process. (default: 0)
  25701. * @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)
  25702. */
  25703. 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);
  25704. }
  25705. }
  25706. declare module BABYLON {
  25707. /**
  25708. * Specifies the level of max blur that should be applied when using the depth of field effect
  25709. */
  25710. enum DepthOfFieldEffectBlurLevel {
  25711. /**
  25712. * Subtle blur
  25713. */
  25714. Low = 0,
  25715. /**
  25716. * Medium blur
  25717. */
  25718. Medium = 1,
  25719. /**
  25720. * Large blur
  25721. */
  25722. High = 2,
  25723. }
  25724. /**
  25725. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25726. */
  25727. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25728. private _circleOfConfusion;
  25729. /**
  25730. * Internal, blurs from high to low
  25731. */
  25732. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25733. private _depthOfFieldBlurY;
  25734. private _dofMerge;
  25735. /**
  25736. * Internal post processes in depth of field effect
  25737. */
  25738. _effects: Array<PostProcess>;
  25739. /**
  25740. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25741. */
  25742. focalLength: number;
  25743. /**
  25744. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25745. */
  25746. fStop: number;
  25747. /**
  25748. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25749. */
  25750. focusDistance: number;
  25751. /**
  25752. * 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.
  25753. */
  25754. lensSize: number;
  25755. /**
  25756. * Creates a new instance DepthOfFieldEffect
  25757. * @param scene The scene the effect belongs to.
  25758. * @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.
  25759. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25760. * @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)
  25761. */
  25762. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25763. /**
  25764. * 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.
  25765. */
  25766. depthTexture: RenderTargetTexture;
  25767. /**
  25768. * Disposes each of the internal effects for a given camera.
  25769. * @param camera The camera to dispose the effect on.
  25770. */
  25771. disposeEffects(camera: Camera): void;
  25772. /**
  25773. * Internal
  25774. */
  25775. _updateEffects(): void;
  25776. /**
  25777. * Internal
  25778. * @returns if all the contained post processes are ready.
  25779. */
  25780. _isReady(): boolean;
  25781. }
  25782. }
  25783. declare module BABYLON {
  25784. /**
  25785. * Options to be set when merging outputs from the default pipeline.
  25786. */
  25787. class DepthOfFieldMergePostProcessOptions {
  25788. /**
  25789. * The original image to merge on top of
  25790. */
  25791. originalFromInput: PostProcess;
  25792. /**
  25793. * Parameters to perform the merge of the depth of field effect
  25794. */
  25795. depthOfField?: {
  25796. circleOfConfusion: PostProcess;
  25797. blurSteps: Array<PostProcess>;
  25798. };
  25799. /**
  25800. * Parameters to perform the merge of bloom effect
  25801. */
  25802. bloom?: {
  25803. blurred: PostProcess;
  25804. weight: number;
  25805. };
  25806. }
  25807. /**
  25808. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25809. */
  25810. class DepthOfFieldMergePostProcess extends PostProcess {
  25811. private blurSteps;
  25812. /**
  25813. * Creates a new instance of DepthOfFieldMergePostProcess
  25814. * @param name The name of the effect.
  25815. * @param originalFromInput Post process which's input will be used for the merge.
  25816. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25817. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25818. * @param options The required width/height ratio to downsize to before computing the render pass.
  25819. * @param camera The camera to apply the render pass to.
  25820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25821. * @param engine The engine which the post process will be applied. (default: current engine)
  25822. * @param reusable If the post process can be reused on the same frame. (default: false)
  25823. * @param textureType Type of textures used when performing the post process. (default: 0)
  25824. * @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)
  25825. */
  25826. 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);
  25827. /**
  25828. * Updates the effect with the current post process compile time values and recompiles the shader.
  25829. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25830. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25831. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25832. * @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
  25833. * @param onCompiled Called when the shader has been compiled.
  25834. * @param onError Called if there is an error when compiling a shader.
  25835. */
  25836. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25837. }
  25838. }
  25839. declare module BABYLON {
  25840. class DisplayPassPostProcess extends PostProcess {
  25841. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25842. }
  25843. }
  25844. declare module BABYLON {
  25845. /**
  25846. * 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.
  25847. */
  25848. class ExtractHighlightsPostProcess extends PostProcess {
  25849. /**
  25850. * The luminance threshold, pixels below this value will be set to black.
  25851. */
  25852. threshold: number;
  25853. /**
  25854. * Internal
  25855. */
  25856. _exposure: number;
  25857. /**
  25858. * Post process which has the input texture to be used when performing highlight extraction
  25859. */
  25860. _inputPostProcess: Nullable<PostProcess>;
  25861. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25862. }
  25863. }
  25864. declare module BABYLON {
  25865. class FilterPostProcess extends PostProcess {
  25866. kernelMatrix: Matrix;
  25867. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25868. }
  25869. }
  25870. declare module BABYLON {
  25871. class FxaaPostProcess extends PostProcess {
  25872. texelWidth: number;
  25873. texelHeight: number;
  25874. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25875. private _getDefines();
  25876. }
  25877. }
  25878. declare module BABYLON {
  25879. /**
  25880. * The GrainPostProcess adds noise to the image at mid luminance levels
  25881. */
  25882. class GrainPostProcess extends PostProcess {
  25883. /**
  25884. * The intensity of the grain added (default: 30)
  25885. */
  25886. intensity: number;
  25887. /**
  25888. * If the grain should be randomized on every frame
  25889. */
  25890. animated: boolean;
  25891. /**
  25892. * Creates a new instance of @see GrainPostProcess
  25893. * @param name The name of the effect.
  25894. * @param options The required width/height ratio to downsize to before computing the render pass.
  25895. * @param camera The camera to apply the render pass to.
  25896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25897. * @param engine The engine which the post process will be applied. (default: current engine)
  25898. * @param reusable If the post process can be reused on the same frame. (default: false)
  25899. * @param textureType Type of textures used when performing the post process. (default: 0)
  25900. * @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)
  25901. */
  25902. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25903. }
  25904. }
  25905. declare module BABYLON {
  25906. class HighlightsPostProcess extends PostProcess {
  25907. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25908. }
  25909. }
  25910. declare module BABYLON {
  25911. class ImageProcessingPostProcess extends PostProcess {
  25912. /**
  25913. * Default configuration related to image processing available in the PBR Material.
  25914. */
  25915. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25916. /**
  25917. * Gets the image processing configuration used either in this material.
  25918. */
  25919. /**
  25920. * Sets the Default image processing configuration used either in the this material.
  25921. *
  25922. * If sets to null, the scene one is in use.
  25923. */
  25924. imageProcessingConfiguration: ImageProcessingConfiguration;
  25925. /**
  25926. * Keep track of the image processing observer to allow dispose and replace.
  25927. */
  25928. private _imageProcessingObserver;
  25929. /**
  25930. * Attaches a new image processing configuration to the PBR Material.
  25931. * @param configuration
  25932. */
  25933. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25934. /**
  25935. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25936. */
  25937. /**
  25938. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25939. */
  25940. colorCurves: Nullable<ColorCurves>;
  25941. /**
  25942. * Gets wether the color curves effect is enabled.
  25943. */
  25944. /**
  25945. * Sets wether the color curves effect is enabled.
  25946. */
  25947. colorCurvesEnabled: boolean;
  25948. /**
  25949. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25950. */
  25951. /**
  25952. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25953. */
  25954. colorGradingTexture: Nullable<BaseTexture>;
  25955. /**
  25956. * Gets wether the color grading effect is enabled.
  25957. */
  25958. /**
  25959. * Gets wether the color grading effect is enabled.
  25960. */
  25961. colorGradingEnabled: boolean;
  25962. /**
  25963. * Gets exposure used in the effect.
  25964. */
  25965. /**
  25966. * Sets exposure used in the effect.
  25967. */
  25968. exposure: number;
  25969. /**
  25970. * Gets wether tonemapping is enabled or not.
  25971. */
  25972. /**
  25973. * Sets wether tonemapping is enabled or not
  25974. */
  25975. toneMappingEnabled: boolean;
  25976. /**
  25977. * Gets contrast used in the effect.
  25978. */
  25979. /**
  25980. * Sets contrast used in the effect.
  25981. */
  25982. contrast: number;
  25983. /**
  25984. * Gets Vignette stretch size.
  25985. */
  25986. /**
  25987. * Sets Vignette stretch size.
  25988. */
  25989. vignetteStretch: number;
  25990. /**
  25991. * Gets Vignette centre X Offset.
  25992. */
  25993. /**
  25994. * Sets Vignette centre X Offset.
  25995. */
  25996. vignetteCentreX: number;
  25997. /**
  25998. * Gets Vignette centre Y Offset.
  25999. */
  26000. /**
  26001. * Sets Vignette centre Y Offset.
  26002. */
  26003. vignetteCentreY: number;
  26004. /**
  26005. * Gets Vignette weight or intensity of the vignette effect.
  26006. */
  26007. /**
  26008. * Sets Vignette weight or intensity of the vignette effect.
  26009. */
  26010. vignetteWeight: number;
  26011. /**
  26012. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26013. * if vignetteEnabled is set to true.
  26014. */
  26015. /**
  26016. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26017. * if vignetteEnabled is set to true.
  26018. */
  26019. vignetteColor: Color4;
  26020. /**
  26021. * Gets Camera field of view used by the Vignette effect.
  26022. */
  26023. /**
  26024. * Sets Camera field of view used by the Vignette effect.
  26025. */
  26026. vignetteCameraFov: number;
  26027. /**
  26028. * Gets the vignette blend mode allowing different kind of effect.
  26029. */
  26030. /**
  26031. * Sets the vignette blend mode allowing different kind of effect.
  26032. */
  26033. vignetteBlendMode: number;
  26034. /**
  26035. * Gets wether the vignette effect is enabled.
  26036. */
  26037. /**
  26038. * Sets wether the vignette effect is enabled.
  26039. */
  26040. vignetteEnabled: boolean;
  26041. private _fromLinearSpace;
  26042. /**
  26043. * Gets wether the input of the processing is in Gamma or Linear Space.
  26044. */
  26045. /**
  26046. * Sets wether the input of the processing is in Gamma or Linear Space.
  26047. */
  26048. fromLinearSpace: boolean;
  26049. /**
  26050. * Defines cache preventing GC.
  26051. */
  26052. private _defines;
  26053. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  26054. getClassName(): string;
  26055. protected _updateParameters(): void;
  26056. dispose(camera?: Camera): void;
  26057. }
  26058. }
  26059. declare module BABYLON {
  26060. class PassPostProcess extends PostProcess {
  26061. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26062. }
  26063. }
  26064. declare module BABYLON {
  26065. type PostProcessOptions = {
  26066. width: number;
  26067. height: number;
  26068. };
  26069. /**
  26070. * PostProcess can be used to apply a shader to a texture after it has been rendered
  26071. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26072. */
  26073. class PostProcess {
  26074. /** Name of the PostProcess. */ name: string;
  26075. /**
  26076. * Width of the texture to apply the post process on
  26077. */
  26078. width: number;
  26079. /**
  26080. * Height of the texture to apply the post process on
  26081. */
  26082. height: number;
  26083. /**
  26084. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  26085. */
  26086. _outputTexture: Nullable<InternalTexture>;
  26087. /**
  26088. * Sampling mode used by the shader
  26089. * See https://doc.babylonjs.com/classes/3.1/texture
  26090. */
  26091. renderTargetSamplingMode: number;
  26092. /**
  26093. * Clear color to use when screen clearing
  26094. */
  26095. clearColor: Color4;
  26096. /**
  26097. * If the buffer needs to be cleared before applying the post process. (default: true)
  26098. * Should be set to false if shader will overwrite all previous pixels.
  26099. */
  26100. autoClear: boolean;
  26101. /**
  26102. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  26103. */
  26104. alphaMode: number;
  26105. /**
  26106. * Sets the setAlphaBlendConstants of the babylon engine
  26107. */
  26108. alphaConstants: Color4;
  26109. /**
  26110. * Animations to be used for the post processing
  26111. */
  26112. animations: Animation[];
  26113. /**
  26114. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  26115. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  26116. */
  26117. enablePixelPerfectMode: boolean;
  26118. /**
  26119. * Force the postprocess to be applied without taking in account viewport
  26120. */
  26121. forceFullscreenViewport: boolean;
  26122. /**
  26123. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  26124. *
  26125. * | Value | Type | Description |
  26126. * | ----- | ----------------------------------- | ----------- |
  26127. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  26128. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  26129. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  26130. *
  26131. */
  26132. scaleMode: number;
  26133. /**
  26134. * Force textures to be a power of two (default: false)
  26135. */
  26136. alwaysForcePOT: boolean;
  26137. /**
  26138. * Number of sample textures (default: 1)
  26139. */
  26140. samples: number;
  26141. /**
  26142. * Modify the scale of the post process to be the same as the viewport (default: false)
  26143. */
  26144. adaptScaleToCurrentViewport: boolean;
  26145. private _camera;
  26146. private _scene;
  26147. private _engine;
  26148. private _options;
  26149. private _reusable;
  26150. private _textureType;
  26151. /**
  26152. * Smart array of input and output textures for the post process.
  26153. */
  26154. _textures: SmartArray<InternalTexture>;
  26155. /**
  26156. * The index in _textures that corresponds to the output texture.
  26157. */
  26158. _currentRenderTextureInd: number;
  26159. private _effect;
  26160. private _samplers;
  26161. private _fragmentUrl;
  26162. private _vertexUrl;
  26163. private _parameters;
  26164. private _scaleRatio;
  26165. protected _indexParameters: any;
  26166. private _shareOutputWithPostProcess;
  26167. private _texelSize;
  26168. private _forcedOutputTexture;
  26169. /**
  26170. * An event triggered when the postprocess is activated.
  26171. */
  26172. onActivateObservable: Observable<Camera>;
  26173. private _onActivateObserver;
  26174. /**
  26175. * A function that is added to the onActivateObservable
  26176. */
  26177. onActivate: Nullable<(camera: Camera) => void>;
  26178. /**
  26179. * An event triggered when the postprocess changes its size.
  26180. */
  26181. onSizeChangedObservable: Observable<PostProcess>;
  26182. private _onSizeChangedObserver;
  26183. /**
  26184. * A function that is added to the onSizeChangedObservable
  26185. */
  26186. onSizeChanged: (postProcess: PostProcess) => void;
  26187. /**
  26188. * An event triggered when the postprocess applies its effect.
  26189. */
  26190. onApplyObservable: Observable<Effect>;
  26191. private _onApplyObserver;
  26192. /**
  26193. * A function that is added to the onApplyObservable
  26194. */
  26195. onApply: (effect: Effect) => void;
  26196. /**
  26197. * An event triggered before rendering the postprocess
  26198. */
  26199. onBeforeRenderObservable: Observable<Effect>;
  26200. private _onBeforeRenderObserver;
  26201. /**
  26202. * A function that is added to the onBeforeRenderObservable
  26203. */
  26204. onBeforeRender: (effect: Effect) => void;
  26205. /**
  26206. * An event triggered after rendering the postprocess
  26207. */
  26208. onAfterRenderObservable: Observable<Effect>;
  26209. private _onAfterRenderObserver;
  26210. /**
  26211. * A function that is added to the onAfterRenderObservable
  26212. */
  26213. onAfterRender: (efect: Effect) => void;
  26214. /**
  26215. * 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
  26216. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26217. */
  26218. inputTexture: InternalTexture;
  26219. /**
  26220. * Gets the camera which post process is applied to.
  26221. * @returns The camera the post process is applied to.
  26222. */
  26223. getCamera(): Camera;
  26224. /**
  26225. * Gets the texel size of the postprocess.
  26226. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26227. */
  26228. readonly texelSize: Vector2;
  26229. /**
  26230. * Creates a new instance PostProcess
  26231. * @param name The name of the PostProcess.
  26232. * @param fragmentUrl The url of the fragment shader to be used.
  26233. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26234. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26235. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26236. * @param camera The camera to apply the render pass to.
  26237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26238. * @param engine The engine which the post process will be applied. (default: current engine)
  26239. * @param reusable If the post process can be reused on the same frame. (default: false)
  26240. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26241. * @param textureType Type of textures used when performing the post process. (default: 0)
  26242. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26243. * @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
  26244. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26245. */
  26246. 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);
  26247. /**
  26248. * Gets the engine which this post process belongs to.
  26249. * @returns The engine the post process was enabled with.
  26250. */
  26251. getEngine(): Engine;
  26252. /**
  26253. * The effect that is created when initializing the post process.
  26254. * @returns The created effect corrisponding the the postprocess.
  26255. */
  26256. getEffect(): Effect;
  26257. /**
  26258. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26259. * @param postProcess The post process to share the output with.
  26260. * @returns This post process.
  26261. */
  26262. shareOutputWith(postProcess: PostProcess): PostProcess;
  26263. /**
  26264. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26265. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26266. */
  26267. useOwnOutput(): void;
  26268. /**
  26269. * Updates the effect with the current post process compile time values and recompiles the shader.
  26270. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26271. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26272. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26273. * @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
  26274. * @param onCompiled Called when the shader has been compiled.
  26275. * @param onError Called if there is an error when compiling a shader.
  26276. */
  26277. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26278. /**
  26279. * The post process is reusable if it can be used multiple times within one frame.
  26280. * @returns If the post process is reusable
  26281. */
  26282. isReusable(): boolean;
  26283. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26284. markTextureDirty(): void;
  26285. /**
  26286. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26287. * 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.
  26288. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26289. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26290. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26291. * @returns The target texture that was bound to be written to.
  26292. */
  26293. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26294. /**
  26295. * If the post process is supported.
  26296. */
  26297. readonly isSupported: boolean;
  26298. /**
  26299. * The aspect ratio of the output texture.
  26300. */
  26301. readonly aspectRatio: number;
  26302. /**
  26303. * Get a value indicating if the post-process is ready to be used
  26304. * @returns true if the post-process is ready (shader is compiled)
  26305. */
  26306. isReady(): boolean;
  26307. /**
  26308. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26309. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26310. */
  26311. apply(): Nullable<Effect>;
  26312. private _disposeTextures();
  26313. /**
  26314. * Disposes the post process.
  26315. * @param camera The camera to dispose the post process on.
  26316. */
  26317. dispose(camera?: Camera): void;
  26318. }
  26319. }
  26320. declare module BABYLON {
  26321. /**
  26322. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26323. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26324. */
  26325. class PostProcessManager {
  26326. private _scene;
  26327. private _indexBuffer;
  26328. private _vertexBuffers;
  26329. /**
  26330. * Creates a new instance PostProcess
  26331. * @param scene The scene that the post process is associated with.
  26332. */
  26333. constructor(scene: Scene);
  26334. private _prepareBuffers();
  26335. private _buildIndexBuffer();
  26336. /**
  26337. * Rebuilds the vertex buffers of the manager.
  26338. */
  26339. _rebuild(): void;
  26340. /**
  26341. * Prepares a frame to be run through a post process.
  26342. * @param sourceTexture The input texture to the post procesess. (default: null)
  26343. * @param postProcesses An array of post processes to be run. (default: null)
  26344. * @returns True if the post processes were able to be run.
  26345. */
  26346. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  26347. /**
  26348. * Manually render a set of post processes to a texture.
  26349. * @param postProcesses An array of post processes to be run.
  26350. * @param targetTexture The target texture to render to.
  26351. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26352. */
  26353. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  26354. /**
  26355. * Finalize the result of the output of the postprocesses.
  26356. * @param doNotPresent If true the result will not be displayed to the screen.
  26357. * @param targetTexture The target texture to render to.
  26358. * @param faceIndex The index of the face to bind the target texture to.
  26359. * @param postProcesses The array of post processes to render.
  26360. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26361. */
  26362. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  26363. /**
  26364. * Disposes of the post process manager.
  26365. */
  26366. dispose(): void;
  26367. }
  26368. }
  26369. declare module BABYLON {
  26370. class RefractionPostProcess extends PostProcess {
  26371. color: Color3;
  26372. depth: number;
  26373. colorLevel: number;
  26374. private _refTexture;
  26375. private _ownRefractionTexture;
  26376. /**
  26377. * Gets or sets the refraction texture
  26378. * Please note that you are responsible for disposing the texture if you set it manually
  26379. */
  26380. refractionTexture: Texture;
  26381. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26382. dispose(camera: Camera): void;
  26383. }
  26384. }
  26385. declare module BABYLON {
  26386. /**
  26387. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26388. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26389. */
  26390. class SharpenPostProcess extends PostProcess {
  26391. /**
  26392. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26393. */
  26394. colorAmount: number;
  26395. /**
  26396. * How much sharpness should be applied (default: 0.3)
  26397. */
  26398. edgeAmount: number;
  26399. /**
  26400. * Creates a new instance ConvolutionPostProcess
  26401. * @param name The name of the effect.
  26402. * @param options The required width/height ratio to downsize to before computing the render pass.
  26403. * @param camera The camera to apply the render pass to.
  26404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26405. * @param engine The engine which the post process will be applied. (default: current engine)
  26406. * @param reusable If the post process can be reused on the same frame. (default: false)
  26407. * @param textureType Type of textures used when performing the post process. (default: 0)
  26408. * @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)
  26409. */
  26410. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26411. }
  26412. }
  26413. declare module BABYLON {
  26414. class StereoscopicInterlacePostProcess extends PostProcess {
  26415. private _stepSize;
  26416. private _passedProcess;
  26417. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26418. }
  26419. }
  26420. declare module BABYLON {
  26421. /** Defines operator used for tonemapping */
  26422. enum TonemappingOperator {
  26423. /** Hable */
  26424. Hable = 0,
  26425. /** Reinhard */
  26426. Reinhard = 1,
  26427. /** HejiDawson */
  26428. HejiDawson = 2,
  26429. /** Photographic */
  26430. Photographic = 3,
  26431. }
  26432. /**
  26433. * Defines a post process to apply tone mapping
  26434. */
  26435. class TonemapPostProcess extends PostProcess {
  26436. private _operator;
  26437. /** Defines the required exposure adjustement */
  26438. exposureAdjustment: number;
  26439. /**
  26440. * Creates a new TonemapPostProcess
  26441. * @param name defines the name of the postprocess
  26442. * @param _operator defines the operator to use
  26443. * @param exposureAdjustment defines the required exposure adjustement
  26444. * @param camera defines the camera to use (can be null)
  26445. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26446. * @param engine defines the hosting engine (can be ignore if camera is set)
  26447. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26448. */
  26449. constructor(name: string, _operator: TonemappingOperator,
  26450. /** Defines the required exposure adjustement */
  26451. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26452. }
  26453. }
  26454. declare module BABYLON {
  26455. class VolumetricLightScatteringPostProcess extends PostProcess {
  26456. private _volumetricLightScatteringPass;
  26457. private _volumetricLightScatteringRTT;
  26458. private _viewPort;
  26459. private _screenCoordinates;
  26460. private _cachedDefines;
  26461. /**
  26462. * If not undefined, the mesh position is computed from the attached node position
  26463. */
  26464. attachedNode: {
  26465. position: Vector3;
  26466. };
  26467. /**
  26468. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26469. */
  26470. customMeshPosition: Vector3;
  26471. /**
  26472. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26473. */
  26474. useCustomMeshPosition: boolean;
  26475. /**
  26476. * If the post-process should inverse the light scattering direction
  26477. */
  26478. invert: boolean;
  26479. /**
  26480. * The internal mesh used by the post-process
  26481. */
  26482. mesh: Mesh;
  26483. useDiffuseColor: boolean;
  26484. /**
  26485. * Array containing the excluded meshes not rendered in the internal pass
  26486. */
  26487. excludedMeshes: AbstractMesh[];
  26488. /**
  26489. * Controls the overall intensity of the post-process
  26490. */
  26491. exposure: number;
  26492. /**
  26493. * Dissipates each sample's contribution in range [0, 1]
  26494. */
  26495. decay: number;
  26496. /**
  26497. * Controls the overall intensity of each sample
  26498. */
  26499. weight: number;
  26500. /**
  26501. * Controls the density of each sample
  26502. */
  26503. density: number;
  26504. /**
  26505. * @constructor
  26506. * @param {string} name - The post-process name
  26507. * @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)
  26508. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26509. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26510. * @param {number} samples - The post-process quality, default 100
  26511. * @param {number} samplingMode - The post-process filtering mode
  26512. * @param {BABYLON.Engine} engine - The babylon engine
  26513. * @param {boolean} reusable - If the post-process is reusable
  26514. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26515. */
  26516. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26517. getClassName(): string;
  26518. private _isReady(subMesh, useInstances);
  26519. /**
  26520. * Sets the new light position for light scattering effect
  26521. * @param {BABYLON.Vector3} The new custom light position
  26522. */
  26523. setCustomMeshPosition(position: Vector3): void;
  26524. /**
  26525. * Returns the light position for light scattering effect
  26526. * @return {BABYLON.Vector3} The custom light position
  26527. */
  26528. getCustomMeshPosition(): Vector3;
  26529. /**
  26530. * Disposes the internal assets and detaches the post-process from the camera
  26531. */
  26532. dispose(camera: Camera): void;
  26533. /**
  26534. * Returns the render target texture used by the post-process
  26535. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26536. */
  26537. getPass(): RenderTargetTexture;
  26538. private _meshExcluded(mesh);
  26539. private _createPass(scene, ratio);
  26540. private _updateMeshScreenCoordinates(scene);
  26541. /**
  26542. * Creates a default mesh for the Volumeric Light Scattering post-process
  26543. * @param {string} The mesh name
  26544. * @param {BABYLON.Scene} The scene where to create the mesh
  26545. * @return {BABYLON.Mesh} the default mesh
  26546. */
  26547. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26548. }
  26549. }
  26550. declare module BABYLON {
  26551. class VRDistortionCorrectionPostProcess extends PostProcess {
  26552. private _isRightEye;
  26553. private _distortionFactors;
  26554. private _postProcessScaleFactor;
  26555. private _lensCenterOffset;
  26556. private _scaleIn;
  26557. private _scaleFactor;
  26558. private _lensCenter;
  26559. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26560. }
  26561. }
  26562. declare module BABYLON {
  26563. class BoundingBoxRenderer {
  26564. frontColor: Color3;
  26565. backColor: Color3;
  26566. showBackLines: boolean;
  26567. renderList: SmartArray<BoundingBox>;
  26568. private _scene;
  26569. private _colorShader;
  26570. private _vertexBuffers;
  26571. private _indexBuffer;
  26572. constructor(scene: Scene);
  26573. private _prepareRessources();
  26574. private _createIndexBuffer();
  26575. _rebuild(): void;
  26576. reset(): void;
  26577. render(): void;
  26578. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26579. dispose(): void;
  26580. }
  26581. }
  26582. declare module BABYLON {
  26583. /**
  26584. * This represents a depth renderer in Babylon.
  26585. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26586. */
  26587. class DepthRenderer {
  26588. private _scene;
  26589. private _depthMap;
  26590. private _effect;
  26591. private _cachedDefines;
  26592. private _camera;
  26593. /**
  26594. * Instantiates a depth renderer
  26595. * @param scene The scene the renderer belongs to
  26596. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26597. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26598. */
  26599. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26600. /**
  26601. * Creates the depth rendering effect and checks if the effect is ready.
  26602. * @param subMesh The submesh to be used to render the depth map of
  26603. * @param useInstances If multiple world instances should be used
  26604. * @returns if the depth renderer is ready to render the depth map
  26605. */
  26606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26607. /**
  26608. * Gets the texture which the depth map will be written to.
  26609. * @returns The depth map texture
  26610. */
  26611. getDepthMap(): RenderTargetTexture;
  26612. /**
  26613. * Disposes of the depth renderer.
  26614. */
  26615. dispose(): void;
  26616. }
  26617. }
  26618. declare module BABYLON {
  26619. class EdgesRenderer {
  26620. edgesWidthScalerForOrthographic: number;
  26621. edgesWidthScalerForPerspective: number;
  26622. private _source;
  26623. private _linesPositions;
  26624. private _linesNormals;
  26625. private _linesIndices;
  26626. private _epsilon;
  26627. private _indicesCount;
  26628. private _lineShader;
  26629. private _ib;
  26630. private _buffers;
  26631. private _checkVerticesInsteadOfIndices;
  26632. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  26633. isEnabled: boolean;
  26634. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26635. private _prepareRessources();
  26636. _rebuild(): void;
  26637. dispose(): void;
  26638. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26639. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26640. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26641. _generateEdgesLines(): void;
  26642. render(): void;
  26643. }
  26644. }
  26645. declare module BABYLON {
  26646. /**
  26647. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26648. */
  26649. class GeometryBufferRenderer {
  26650. private _scene;
  26651. private _multiRenderTarget;
  26652. private _ratio;
  26653. private _enablePosition;
  26654. protected _effect: Effect;
  26655. protected _cachedDefines: string;
  26656. /**
  26657. * Set the render list (meshes to be rendered) used in the G buffer.
  26658. */
  26659. renderList: Mesh[];
  26660. /**
  26661. * Gets wether or not G buffer are supported by the running hardware.
  26662. * This requires draw buffer supports
  26663. */
  26664. readonly isSupported: boolean;
  26665. /**
  26666. * Gets wether or not position are enabled for the G buffer.
  26667. */
  26668. /**
  26669. * Sets wether or not position are enabled for the G buffer.
  26670. */
  26671. enablePosition: boolean;
  26672. /**
  26673. * Gets the scene associated with the buffer.
  26674. */
  26675. readonly scene: Scene;
  26676. /**
  26677. * Gets the ratio used by the buffer during its creation.
  26678. * How big is the buffer related to the main canvas.
  26679. */
  26680. readonly ratio: number;
  26681. /**
  26682. * Creates a new G Buffer for the scene
  26683. * @param scene The scene the buffer belongs to
  26684. * @param ratio How big is the buffer related to the main canvas.
  26685. */
  26686. constructor(scene: Scene, ratio?: number);
  26687. /**
  26688. * Checks wether everything is ready to render a submesh to the G buffer.
  26689. * @param subMesh the submesh to check readiness for
  26690. * @param useInstances is the mesh drawn using instance or not
  26691. * @returns true if ready otherwise false
  26692. */
  26693. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26694. /**
  26695. * Gets the current underlying G Buffer.
  26696. * @returns the buffer
  26697. */
  26698. getGBuffer(): MultiRenderTarget;
  26699. /**
  26700. * Gets the number of samples used to render the buffer (anti aliasing).
  26701. */
  26702. /**
  26703. * Sets the number of samples used to render the buffer (anti aliasing).
  26704. */
  26705. samples: number;
  26706. /**
  26707. * Disposes the renderer and frees up associated resources.
  26708. */
  26709. dispose(): void;
  26710. protected _createRenderTargets(): void;
  26711. }
  26712. }
  26713. declare module BABYLON {
  26714. class OutlineRenderer {
  26715. private _scene;
  26716. private _effect;
  26717. private _cachedDefines;
  26718. zOffset: number;
  26719. constructor(scene: Scene);
  26720. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26722. }
  26723. }
  26724. declare module BABYLON {
  26725. class RenderingGroup {
  26726. index: number;
  26727. private _scene;
  26728. private _opaqueSubMeshes;
  26729. private _transparentSubMeshes;
  26730. private _alphaTestSubMeshes;
  26731. private _depthOnlySubMeshes;
  26732. private _particleSystems;
  26733. private _spriteManagers;
  26734. private _opaqueSortCompareFn;
  26735. private _alphaTestSortCompareFn;
  26736. private _transparentSortCompareFn;
  26737. private _renderOpaque;
  26738. private _renderAlphaTest;
  26739. private _renderTransparent;
  26740. private _edgesRenderers;
  26741. onBeforeTransparentRendering: () => void;
  26742. /**
  26743. * Set the opaque sort comparison function.
  26744. * If null the sub meshes will be render in the order they were created
  26745. */
  26746. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26747. /**
  26748. * Set the alpha test sort comparison function.
  26749. * If null the sub meshes will be render in the order they were created
  26750. */
  26751. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26752. /**
  26753. * Set the transparent sort comparison function.
  26754. * If null the sub meshes will be render in the order they were created
  26755. */
  26756. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26757. /**
  26758. * Creates a new rendering group.
  26759. * @param index The rendering group index
  26760. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26761. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26762. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26763. */
  26764. 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>);
  26765. /**
  26766. * Render all the sub meshes contained in the group.
  26767. * @param customRenderFunction Used to override the default render behaviour of the group.
  26768. * @returns true if rendered some submeshes.
  26769. */
  26770. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26771. /**
  26772. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26773. * @param subMeshes The submeshes to render
  26774. */
  26775. private renderOpaqueSorted(subMeshes);
  26776. /**
  26777. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26778. * @param subMeshes The submeshes to render
  26779. */
  26780. private renderAlphaTestSorted(subMeshes);
  26781. /**
  26782. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26783. * @param subMeshes The submeshes to render
  26784. */
  26785. private renderTransparentSorted(subMeshes);
  26786. /**
  26787. * Renders the submeshes in a specified order.
  26788. * @param subMeshes The submeshes to sort before render
  26789. * @param sortCompareFn The comparison function use to sort
  26790. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26791. * @param transparent Specifies to activate blending if true
  26792. */
  26793. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26794. /**
  26795. * Renders the submeshes in the order they were dispatched (no sort applied).
  26796. * @param subMeshes The submeshes to render
  26797. */
  26798. private static renderUnsorted(subMeshes);
  26799. /**
  26800. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26801. * are rendered back to front if in the same alpha index.
  26802. *
  26803. * @param a The first submesh
  26804. * @param b The second submesh
  26805. * @returns The result of the comparison
  26806. */
  26807. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26808. /**
  26809. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26810. * are rendered back to front.
  26811. *
  26812. * @param a The first submesh
  26813. * @param b The second submesh
  26814. * @returns The result of the comparison
  26815. */
  26816. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26817. /**
  26818. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26819. * are rendered front to back (prevent overdraw).
  26820. *
  26821. * @param a The first submesh
  26822. * @param b The second submesh
  26823. * @returns The result of the comparison
  26824. */
  26825. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26826. /**
  26827. * Resets the different lists of submeshes to prepare a new frame.
  26828. */
  26829. prepare(): void;
  26830. dispose(): void;
  26831. /**
  26832. * Inserts the submesh in its correct queue depending on its material.
  26833. * @param subMesh The submesh to dispatch
  26834. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26835. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26836. */
  26837. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26838. dispatchSprites(spriteManager: SpriteManager): void;
  26839. dispatchParticles(particleSystem: IParticleSystem): void;
  26840. private _renderParticles(activeMeshes);
  26841. private _renderSprites();
  26842. }
  26843. }
  26844. declare module BABYLON {
  26845. class RenderingManager {
  26846. /**
  26847. * The max id used for rendering groups (not included)
  26848. */
  26849. static MAX_RENDERINGGROUPS: number;
  26850. /**
  26851. * The min id used for rendering groups (included)
  26852. */
  26853. static MIN_RENDERINGGROUPS: number;
  26854. /**
  26855. * Used to globally prevent autoclearing scenes.
  26856. */
  26857. static AUTOCLEAR: boolean;
  26858. private _scene;
  26859. private _renderingGroups;
  26860. private _depthStencilBufferAlreadyCleaned;
  26861. private _autoClearDepthStencil;
  26862. private _customOpaqueSortCompareFn;
  26863. private _customAlphaTestSortCompareFn;
  26864. private _customTransparentSortCompareFn;
  26865. private _renderinGroupInfo;
  26866. constructor(scene: Scene);
  26867. private _clearDepthStencilBuffer(depth?, stencil?);
  26868. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26869. reset(): void;
  26870. dispose(): void;
  26871. /**
  26872. * Clear the info related to rendering groups preventing retention points during dispose.
  26873. */
  26874. freeRenderingGroups(): void;
  26875. private _prepareRenderingGroup(renderingGroupId);
  26876. dispatchSprites(spriteManager: SpriteManager): void;
  26877. dispatchParticles(particleSystem: IParticleSystem): void;
  26878. /**
  26879. * @param subMesh The submesh to dispatch
  26880. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26881. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26882. */
  26883. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26884. /**
  26885. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26886. * This allowed control for front to back rendering or reversly depending of the special needs.
  26887. *
  26888. * @param renderingGroupId The rendering group id corresponding to its index
  26889. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26890. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26891. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26892. */
  26893. 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;
  26894. /**
  26895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26896. *
  26897. * @param renderingGroupId The rendering group id corresponding to its index
  26898. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26899. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26900. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26901. */
  26902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26903. }
  26904. }
  26905. declare module BABYLON {
  26906. /**
  26907. * Renders a layer on top of an existing scene
  26908. */
  26909. class UtilityLayerRenderer implements IDisposable {
  26910. /** the original scene that will be rendered on top of */ originalScene: Scene;
  26911. /**
  26912. * The scene that is rendered on top of the original scene
  26913. */
  26914. utilityLayerScene: Scene;
  26915. /**
  26916. * If the utility layer should automatically be rendered on top of existing scene
  26917. */
  26918. shouldRender: boolean;
  26919. private _afterRenderObserver;
  26920. private _sceneDisposeObserver;
  26921. /**
  26922. * Instantiates a UtilityLayerRenderer
  26923. * @param originalScene the original scene that will be rendered on top of
  26924. */
  26925. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  26926. /**
  26927. * Renders the utility layers scene on top of the original scene
  26928. */
  26929. render(): void;
  26930. /**
  26931. * Disposes of the renderer
  26932. */
  26933. dispose(): void;
  26934. private _updateCamera();
  26935. }
  26936. }
  26937. declare module BABYLON {
  26938. class Sprite {
  26939. name: string;
  26940. position: Vector3;
  26941. color: Color4;
  26942. width: number;
  26943. height: number;
  26944. angle: number;
  26945. cellIndex: number;
  26946. invertU: number;
  26947. invertV: number;
  26948. disposeWhenFinishedAnimating: boolean;
  26949. animations: Animation[];
  26950. isPickable: boolean;
  26951. actionManager: ActionManager;
  26952. private _animationStarted;
  26953. private _loopAnimation;
  26954. private _fromIndex;
  26955. private _toIndex;
  26956. private _delay;
  26957. private _direction;
  26958. private _manager;
  26959. private _time;
  26960. private _onAnimationEnd;
  26961. size: number;
  26962. constructor(name: string, manager: SpriteManager);
  26963. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26964. stopAnimation(): void;
  26965. _animate(deltaTime: number): void;
  26966. dispose(): void;
  26967. }
  26968. }
  26969. declare module BABYLON {
  26970. class SpriteManager {
  26971. name: string;
  26972. sprites: Sprite[];
  26973. renderingGroupId: number;
  26974. layerMask: number;
  26975. fogEnabled: boolean;
  26976. isPickable: boolean;
  26977. cellWidth: number;
  26978. cellHeight: number;
  26979. /**
  26980. * An event triggered when the manager is disposed.
  26981. */
  26982. onDisposeObservable: Observable<SpriteManager>;
  26983. private _onDisposeObserver;
  26984. onDispose: () => void;
  26985. private _capacity;
  26986. private _spriteTexture;
  26987. private _epsilon;
  26988. private _scene;
  26989. private _vertexData;
  26990. private _buffer;
  26991. private _vertexBuffers;
  26992. private _indexBuffer;
  26993. private _effectBase;
  26994. private _effectFog;
  26995. texture: Texture;
  26996. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26997. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26998. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26999. render(): void;
  27000. dispose(): void;
  27001. }
  27002. }
  27003. declare module BABYLON {
  27004. /**
  27005. * @hidden
  27006. **/
  27007. class _AlphaState {
  27008. private _isAlphaBlendDirty;
  27009. private _isBlendFunctionParametersDirty;
  27010. private _isBlendEquationParametersDirty;
  27011. private _isBlendConstantsDirty;
  27012. private _alphaBlend;
  27013. private _blendFunctionParameters;
  27014. private _blendEquationParameters;
  27015. private _blendConstants;
  27016. /**
  27017. * Initializes the state.
  27018. */
  27019. constructor();
  27020. readonly isDirty: boolean;
  27021. alphaBlend: boolean;
  27022. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  27023. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  27024. setAlphaEquationParameters(rgb: number, alpha: number): void;
  27025. reset(): void;
  27026. apply(gl: WebGLRenderingContext): void;
  27027. }
  27028. }
  27029. declare module BABYLON {
  27030. /**
  27031. * @hidden
  27032. **/
  27033. class _DepthCullingState {
  27034. private _isDepthTestDirty;
  27035. private _isDepthMaskDirty;
  27036. private _isDepthFuncDirty;
  27037. private _isCullFaceDirty;
  27038. private _isCullDirty;
  27039. private _isZOffsetDirty;
  27040. private _isFrontFaceDirty;
  27041. private _depthTest;
  27042. private _depthMask;
  27043. private _depthFunc;
  27044. private _cull;
  27045. private _cullFace;
  27046. private _zOffset;
  27047. private _frontFace;
  27048. /**
  27049. * Initializes the state.
  27050. */
  27051. constructor();
  27052. readonly isDirty: boolean;
  27053. zOffset: number;
  27054. cullFace: Nullable<number>;
  27055. cull: Nullable<boolean>;
  27056. depthFunc: Nullable<number>;
  27057. depthMask: boolean;
  27058. depthTest: boolean;
  27059. frontFace: Nullable<number>;
  27060. reset(): void;
  27061. apply(gl: WebGLRenderingContext): void;
  27062. }
  27063. }
  27064. declare module BABYLON {
  27065. /**
  27066. * @hidden
  27067. **/
  27068. class _StencilState {
  27069. private _isStencilTestDirty;
  27070. private _isStencilMaskDirty;
  27071. private _isStencilFuncDirty;
  27072. private _isStencilOpDirty;
  27073. private _stencilTest;
  27074. private _stencilMask;
  27075. private _stencilFunc;
  27076. private _stencilFuncRef;
  27077. private _stencilFuncMask;
  27078. private _stencilOpStencilFail;
  27079. private _stencilOpDepthFail;
  27080. private _stencilOpStencilDepthPass;
  27081. readonly isDirty: boolean;
  27082. stencilFunc: number;
  27083. stencilFuncRef: number;
  27084. stencilFuncMask: number;
  27085. stencilOpStencilFail: number;
  27086. stencilOpDepthFail: number;
  27087. stencilOpStencilDepthPass: number;
  27088. stencilMask: number;
  27089. stencilTest: boolean;
  27090. constructor();
  27091. reset(): void;
  27092. apply(gl: WebGLRenderingContext): void;
  27093. }
  27094. }
  27095. declare module BABYLON {
  27096. /**
  27097. * Class used to evalaute queries containing `and` and `or` operators
  27098. */
  27099. class AndOrNotEvaluator {
  27100. /**
  27101. * Evaluate a query
  27102. * @param query defines the query to evaluate
  27103. * @param evaluateCallback defines the callback used to filter result
  27104. * @returns true if the query matches
  27105. */
  27106. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  27107. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  27108. private static _SimplifyNegation(booleanString);
  27109. }
  27110. }
  27111. declare module BABYLON {
  27112. /**
  27113. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  27114. */
  27115. enum AssetTaskState {
  27116. /**
  27117. * Initialization
  27118. */
  27119. INIT = 0,
  27120. /**
  27121. * Running
  27122. */
  27123. RUNNING = 1,
  27124. /**
  27125. * Done
  27126. */
  27127. DONE = 2,
  27128. /**
  27129. * Error
  27130. */
  27131. ERROR = 3,
  27132. }
  27133. /**
  27134. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  27135. */
  27136. abstract class AbstractAssetTask {
  27137. /**
  27138. * Task name
  27139. */ name: string;
  27140. /**
  27141. * Callback called when the task is successful
  27142. */
  27143. onSuccess: (task: any) => void;
  27144. /**
  27145. * Callback called when the task is not successful
  27146. */
  27147. onError: (task: any, message?: string, exception?: any) => void;
  27148. /**
  27149. * Creates a new {BABYLON.AssetsManager}
  27150. * @param name defines the name of the task
  27151. */
  27152. constructor(
  27153. /**
  27154. * Task name
  27155. */ name: string);
  27156. private _isCompleted;
  27157. private _taskState;
  27158. private _errorObject;
  27159. /**
  27160. * Get if the task is completed
  27161. */
  27162. readonly isCompleted: boolean;
  27163. /**
  27164. * Gets the current state of the task
  27165. */
  27166. readonly taskState: AssetTaskState;
  27167. /**
  27168. * Gets the current error object (if task is in error)
  27169. */
  27170. readonly errorObject: {
  27171. message?: string;
  27172. exception?: any;
  27173. };
  27174. /**
  27175. * Internal only
  27176. * @hidden
  27177. */
  27178. _setErrorObject(message?: string, exception?: any): void;
  27179. /**
  27180. * Execute the current task
  27181. * @param scene defines the scene where you want your assets to be loaded
  27182. * @param onSuccess is a callback called when the task is successfully executed
  27183. * @param onError is a callback called if an error occurs
  27184. */
  27185. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27186. /**
  27187. * Execute the current task
  27188. * @param scene defines the scene where you want your assets to be loaded
  27189. * @param onSuccess is a callback called when the task is successfully executed
  27190. * @param onError is a callback called if an error occurs
  27191. */
  27192. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27193. private onErrorCallback(onError, message?, exception?);
  27194. private onDoneCallback(onSuccess, onError);
  27195. }
  27196. /**
  27197. * Define the interface used by progress events raised during assets loading
  27198. */
  27199. interface IAssetsProgressEvent {
  27200. /**
  27201. * Defines the number of remaining tasks to process
  27202. */
  27203. remainingCount: number;
  27204. /**
  27205. * Defines the total number of tasks
  27206. */
  27207. totalCount: number;
  27208. /**
  27209. * Defines the task that was just processed
  27210. */
  27211. task: AbstractAssetTask;
  27212. }
  27213. /**
  27214. * Class used to share progress information about assets loading
  27215. */
  27216. class AssetsProgressEvent implements IAssetsProgressEvent {
  27217. /**
  27218. * Defines the number of remaining tasks to process
  27219. */
  27220. remainingCount: number;
  27221. /**
  27222. * Defines the total number of tasks
  27223. */
  27224. totalCount: number;
  27225. /**
  27226. * Defines the task that was just processed
  27227. */
  27228. task: AbstractAssetTask;
  27229. /**
  27230. * Creates a {BABYLON.AssetsProgressEvent}
  27231. * @param remainingCount defines the number of remaining tasks to process
  27232. * @param totalCount defines the total number of tasks
  27233. * @param task defines the task that was just processed
  27234. */
  27235. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  27236. }
  27237. /**
  27238. * Define a task used by {BABYLON.AssetsManager} to load meshes
  27239. */
  27240. class MeshAssetTask extends AbstractAssetTask {
  27241. /**
  27242. * Defines the name of the task
  27243. */
  27244. name: string;
  27245. /**
  27246. * Defines the list of mesh's names you want to load
  27247. */
  27248. meshesNames: any;
  27249. /**
  27250. * Defines the root url to use as a base to load your meshes and associated resources
  27251. */
  27252. rootUrl: string;
  27253. /**
  27254. * Defines the filename of the scene to load from
  27255. */
  27256. sceneFilename: string;
  27257. /**
  27258. * Gets the list of loaded meshes
  27259. */
  27260. loadedMeshes: Array<AbstractMesh>;
  27261. /**
  27262. * Gets the list of loaded particle systems
  27263. */
  27264. loadedParticleSystems: Array<ParticleSystem>;
  27265. /**
  27266. * Gets the list of loaded skeletons
  27267. */
  27268. loadedSkeletons: Array<Skeleton>;
  27269. /**
  27270. * Callback called when the task is successful
  27271. */
  27272. onSuccess: (task: MeshAssetTask) => void;
  27273. /**
  27274. * Callback called when the task is successful
  27275. */
  27276. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  27277. /**
  27278. * Creates a new {BABYLON.MeshAssetTask}
  27279. * @param name defines the name of the task
  27280. * @param meshesNames defines the list of mesh's names you want to load
  27281. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  27282. * @param sceneFilename defines the filename of the scene to load from
  27283. */
  27284. constructor(
  27285. /**
  27286. * Defines the name of the task
  27287. */
  27288. name: string,
  27289. /**
  27290. * Defines the list of mesh's names you want to load
  27291. */
  27292. meshesNames: any,
  27293. /**
  27294. * Defines the root url to use as a base to load your meshes and associated resources
  27295. */
  27296. rootUrl: string,
  27297. /**
  27298. * Defines the filename of the scene to load from
  27299. */
  27300. sceneFilename: string);
  27301. /**
  27302. * Execute the current task
  27303. * @param scene defines the scene where you want your assets to be loaded
  27304. * @param onSuccess is a callback called when the task is successfully executed
  27305. * @param onError is a callback called if an error occurs
  27306. */
  27307. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27308. }
  27309. /**
  27310. * Define a task used by {BABYLON.AssetsManager} to load text content
  27311. */
  27312. class TextFileAssetTask extends AbstractAssetTask {
  27313. /**
  27314. * Defines the name of the task
  27315. */
  27316. name: string;
  27317. /**
  27318. * Defines the location of the file to load
  27319. */
  27320. url: string;
  27321. /**
  27322. * Gets the loaded text string
  27323. */
  27324. text: string;
  27325. /**
  27326. * Callback called when the task is successful
  27327. */
  27328. onSuccess: (task: TextFileAssetTask) => void;
  27329. /**
  27330. * Callback called when the task is successful
  27331. */
  27332. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  27333. /**
  27334. * Creates a new TextFileAssetTask object
  27335. * @param name defines the name of the task
  27336. * @param url defines the location of the file to load
  27337. */
  27338. constructor(
  27339. /**
  27340. * Defines the name of the task
  27341. */
  27342. name: string,
  27343. /**
  27344. * Defines the location of the file to load
  27345. */
  27346. url: string);
  27347. /**
  27348. * Execute the current task
  27349. * @param scene defines the scene where you want your assets to be loaded
  27350. * @param onSuccess is a callback called when the task is successfully executed
  27351. * @param onError is a callback called if an error occurs
  27352. */
  27353. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27354. }
  27355. /**
  27356. * Define a task used by {BABYLON.AssetsManager} to load binary data
  27357. */
  27358. class BinaryFileAssetTask extends AbstractAssetTask {
  27359. /**
  27360. * Defines the name of the task
  27361. */
  27362. name: string;
  27363. /**
  27364. * Defines the location of the file to load
  27365. */
  27366. url: string;
  27367. /**
  27368. * Gets the lodaded data (as an array buffer)
  27369. */
  27370. data: ArrayBuffer;
  27371. /**
  27372. * Callback called when the task is successful
  27373. */
  27374. onSuccess: (task: BinaryFileAssetTask) => void;
  27375. /**
  27376. * Callback called when the task is successful
  27377. */
  27378. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  27379. /**
  27380. * Creates a new BinaryFileAssetTask object
  27381. * @param name defines the name of the new task
  27382. * @param url defines the location of the file to load
  27383. */
  27384. constructor(
  27385. /**
  27386. * Defines the name of the task
  27387. */
  27388. name: string,
  27389. /**
  27390. * Defines the location of the file to load
  27391. */
  27392. url: string);
  27393. /**
  27394. * Execute the current task
  27395. * @param scene defines the scene where you want your assets to be loaded
  27396. * @param onSuccess is a callback called when the task is successfully executed
  27397. * @param onError is a callback called if an error occurs
  27398. */
  27399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27400. }
  27401. /**
  27402. * Define a task used by {BABYLON.AssetsManager} to load images
  27403. */
  27404. class ImageAssetTask extends AbstractAssetTask {
  27405. /**
  27406. * Defines the name of the task
  27407. */
  27408. name: string;
  27409. /**
  27410. * Defines the location of the image to load
  27411. */
  27412. url: string;
  27413. /**
  27414. * Gets the loaded images
  27415. */
  27416. image: HTMLImageElement;
  27417. /**
  27418. * Callback called when the task is successful
  27419. */
  27420. onSuccess: (task: ImageAssetTask) => void;
  27421. /**
  27422. * Callback called when the task is successful
  27423. */
  27424. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27425. /**
  27426. * Creates a new ImageAssetTask
  27427. * @param name defines the name of the task
  27428. * @param url defines the location of the image to load
  27429. */
  27430. constructor(
  27431. /**
  27432. * Defines the name of the task
  27433. */
  27434. name: string,
  27435. /**
  27436. * Defines the location of the image to load
  27437. */
  27438. url: string);
  27439. /**
  27440. * Execute the current task
  27441. * @param scene defines the scene where you want your assets to be loaded
  27442. * @param onSuccess is a callback called when the task is successfully executed
  27443. * @param onError is a callback called if an error occurs
  27444. */
  27445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27446. }
  27447. /**
  27448. * Defines the interface used by texture loading tasks
  27449. */
  27450. interface ITextureAssetTask<TEX extends BaseTexture> {
  27451. /**
  27452. * Gets the loaded texture
  27453. */
  27454. texture: TEX;
  27455. }
  27456. /**
  27457. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27458. */
  27459. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27460. /**
  27461. * Defines the name of the task
  27462. */
  27463. name: string;
  27464. /**
  27465. * Defines the location of the file to load
  27466. */
  27467. url: string;
  27468. /**
  27469. * Defines if mipmap should not be generated (default is false)
  27470. */
  27471. noMipmap: boolean | undefined;
  27472. /**
  27473. * Defines if texture must be inverted on Y axis (default is false)
  27474. */
  27475. invertY: boolean | undefined;
  27476. /**
  27477. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27478. */
  27479. samplingMode: number;
  27480. /**
  27481. * Gets the loaded texture
  27482. */
  27483. texture: Texture;
  27484. /**
  27485. * Callback called when the task is successful
  27486. */
  27487. onSuccess: (task: TextureAssetTask) => void;
  27488. /**
  27489. * Callback called when the task is successful
  27490. */
  27491. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  27492. /**
  27493. * Creates a new TextureAssetTask object
  27494. * @param name defines the name of the task
  27495. * @param url defines the location of the file to load
  27496. * @param noMipmap defines if mipmap should not be generated (default is false)
  27497. * @param invertY defines if texture must be inverted on Y axis (default is false)
  27498. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27499. */
  27500. constructor(
  27501. /**
  27502. * Defines the name of the task
  27503. */
  27504. name: string,
  27505. /**
  27506. * Defines the location of the file to load
  27507. */
  27508. url: string,
  27509. /**
  27510. * Defines if mipmap should not be generated (default is false)
  27511. */
  27512. noMipmap?: boolean | undefined,
  27513. /**
  27514. * Defines if texture must be inverted on Y axis (default is false)
  27515. */
  27516. invertY?: boolean | undefined,
  27517. /**
  27518. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27519. */
  27520. samplingMode?: number);
  27521. /**
  27522. * Execute the current task
  27523. * @param scene defines the scene where you want your assets to be loaded
  27524. * @param onSuccess is a callback called when the task is successfully executed
  27525. * @param onError is a callback called if an error occurs
  27526. */
  27527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27528. }
  27529. /**
  27530. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  27531. */
  27532. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  27533. /**
  27534. * Defines the name of the task
  27535. */
  27536. name: string;
  27537. /**
  27538. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27539. */
  27540. url: string;
  27541. /**
  27542. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27543. */
  27544. extensions: string[] | undefined;
  27545. /**
  27546. * Defines if mipmaps should not be generated (default is false)
  27547. */
  27548. noMipmap: boolean | undefined;
  27549. /**
  27550. * Defines the explicit list of files (undefined by default)
  27551. */
  27552. files: string[] | undefined;
  27553. /**
  27554. * Gets the loaded texture
  27555. */
  27556. texture: CubeTexture;
  27557. /**
  27558. * Callback called when the task is successful
  27559. */
  27560. onSuccess: (task: CubeTextureAssetTask) => void;
  27561. /**
  27562. * Callback called when the task is successful
  27563. */
  27564. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  27565. /**
  27566. * Creates a new CubeTextureAssetTask
  27567. * @param name defines the name of the task
  27568. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27569. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27570. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27571. * @param files defines the explicit list of files (undefined by default)
  27572. */
  27573. constructor(
  27574. /**
  27575. * Defines the name of the task
  27576. */
  27577. name: string,
  27578. /**
  27579. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27580. */
  27581. url: string,
  27582. /**
  27583. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27584. */
  27585. extensions?: string[] | undefined,
  27586. /**
  27587. * Defines if mipmaps should not be generated (default is false)
  27588. */
  27589. noMipmap?: boolean | undefined,
  27590. /**
  27591. * Defines the explicit list of files (undefined by default)
  27592. */
  27593. files?: string[] | undefined);
  27594. /**
  27595. * Execute the current task
  27596. * @param scene defines the scene where you want your assets to be loaded
  27597. * @param onSuccess is a callback called when the task is successfully executed
  27598. * @param onError is a callback called if an error occurs
  27599. */
  27600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27601. }
  27602. /**
  27603. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27604. */
  27605. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27606. /**
  27607. * Defines the name of the task
  27608. */
  27609. name: string;
  27610. /**
  27611. * Defines the location of the file to load
  27612. */
  27613. url: string;
  27614. /**
  27615. * Defines the desired size (the more it increases the longer the generation will be)
  27616. */
  27617. size: number;
  27618. /**
  27619. * Defines if mipmaps should not be generated (default is false)
  27620. */
  27621. noMipmap: boolean;
  27622. /**
  27623. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27624. */
  27625. generateHarmonics: boolean;
  27626. /**
  27627. * 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)
  27628. */
  27629. gammaSpace: boolean;
  27630. /**
  27631. * Internal Use Only
  27632. */
  27633. reserved: boolean;
  27634. /**
  27635. * Gets the loaded texture
  27636. */
  27637. texture: HDRCubeTexture;
  27638. /**
  27639. * Callback called when the task is successful
  27640. */
  27641. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27642. /**
  27643. * Callback called when the task is successful
  27644. */
  27645. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27646. /**
  27647. * Creates a new HDRCubeTextureAssetTask object
  27648. * @param name defines the name of the task
  27649. * @param url defines the location of the file to load
  27650. * @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.
  27651. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27652. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27653. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  27654. * @param reserved Internal use only
  27655. */
  27656. constructor(
  27657. /**
  27658. * Defines the name of the task
  27659. */
  27660. name: string,
  27661. /**
  27662. * Defines the location of the file to load
  27663. */
  27664. url: string,
  27665. /**
  27666. * Defines the desired size (the more it increases the longer the generation will be)
  27667. */
  27668. size: number,
  27669. /**
  27670. * Defines if mipmaps should not be generated (default is false)
  27671. */
  27672. noMipmap?: boolean,
  27673. /**
  27674. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27675. */
  27676. generateHarmonics?: boolean,
  27677. /**
  27678. * 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)
  27679. */
  27680. gammaSpace?: boolean,
  27681. /**
  27682. * Internal Use Only
  27683. */
  27684. reserved?: boolean);
  27685. /**
  27686. * Execute the current task
  27687. * @param scene defines the scene where you want your assets to be loaded
  27688. * @param onSuccess is a callback called when the task is successfully executed
  27689. * @param onError is a callback called if an error occurs
  27690. */
  27691. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27692. }
  27693. /**
  27694. * This class can be used to easily import assets into a scene
  27695. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27696. */
  27697. class AssetsManager {
  27698. private _scene;
  27699. private _isLoading;
  27700. protected _tasks: AbstractAssetTask[];
  27701. protected _waitingTasksCount: number;
  27702. protected _totalTasksCount: number;
  27703. /**
  27704. * Callback called when all tasks are processed
  27705. */
  27706. onFinish: (tasks: AbstractAssetTask[]) => void;
  27707. /**
  27708. * Callback called when a task is successful
  27709. */
  27710. onTaskSuccess: (task: AbstractAssetTask) => void;
  27711. /**
  27712. * Callback called when a task had an error
  27713. */
  27714. onTaskError: (task: AbstractAssetTask) => void;
  27715. /**
  27716. * Callback called when a task is done (whatever the result is)
  27717. */
  27718. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27719. /**
  27720. * Observable called when all tasks are processed
  27721. */
  27722. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27723. /**
  27724. * Observable called when a task had an error
  27725. */
  27726. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27727. /**
  27728. * Observable called when a task is successful
  27729. */
  27730. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27731. /**
  27732. * Observable called when a task is done (whatever the result is)
  27733. */
  27734. onProgressObservable: Observable<IAssetsProgressEvent>;
  27735. /**
  27736. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27737. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27738. */
  27739. useDefaultLoadingScreen: boolean;
  27740. /**
  27741. * Creates a new AssetsManager
  27742. * @param scene defines the scene to work on
  27743. */
  27744. constructor(scene: Scene);
  27745. /**
  27746. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27747. * @param taskName defines the name of the new task
  27748. * @param meshesNames defines the name of meshes to load
  27749. * @param rootUrl defines the root url to use to locate files
  27750. * @param sceneFilename defines the filename of the scene file
  27751. * @returns a new {BABYLON.MeshAssetTask} object
  27752. */
  27753. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27754. /**
  27755. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27756. * @param taskName defines the name of the new task
  27757. * @param url defines the url of the file to load
  27758. * @returns a new {BABYLON.TextFileAssetTask} object
  27759. */
  27760. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27761. /**
  27762. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27763. * @param taskName defines the name of the new task
  27764. * @param url defines the url of the file to load
  27765. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27766. */
  27767. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27768. /**
  27769. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27770. * @param taskName defines the name of the new task
  27771. * @param url defines the url of the file to load
  27772. * @returns a new {BABYLON.ImageAssetTask} object
  27773. */
  27774. addImageTask(taskName: string, url: string): ImageAssetTask;
  27775. /**
  27776. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27777. * @param taskName defines the name of the new task
  27778. * @param url defines the url of the file to load
  27779. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27780. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27781. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27782. * @returns a new {BABYLON.TextureAssetTask} object
  27783. */
  27784. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27785. /**
  27786. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27787. * @param taskName defines the name of the new task
  27788. * @param url defines the url of the file to load
  27789. * @param extensions defines the extension to use to load the cube map (can be null)
  27790. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27791. * @param files defines the list of files to load (can be null)
  27792. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27793. */
  27794. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27795. /**
  27796. *
  27797. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27798. * @param taskName defines the name of the new task
  27799. * @param url defines the url of the file to load
  27800. * @param size defines the size you want for the cubemap (can be null)
  27801. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27802. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27803. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  27804. * @param reserved Internal use only
  27805. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27806. */
  27807. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27808. private _decreaseWaitingTasksCount(task);
  27809. private _runTask(task);
  27810. /**
  27811. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27812. * @return the current instance of the {BABYLON.AssetsManager}
  27813. */
  27814. reset(): AssetsManager;
  27815. /**
  27816. * Start the loading process
  27817. * @return the current instance of the {BABYLON.AssetsManager}
  27818. */
  27819. load(): AssetsManager;
  27820. }
  27821. }
  27822. declare module BABYLON {
  27823. /**
  27824. * Class used to enable access to IndexedDB
  27825. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27826. */
  27827. class Database {
  27828. private callbackManifestChecked;
  27829. private currentSceneUrl;
  27830. private db;
  27831. private _enableSceneOffline;
  27832. private _enableTexturesOffline;
  27833. private manifestVersionFound;
  27834. private mustUpdateRessources;
  27835. private hasReachedQuota;
  27836. private isSupported;
  27837. private idbFactory;
  27838. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27839. static IsUASupportingBlobStorage: boolean;
  27840. /** Gets a boolean indicating if Database storate is enabled */
  27841. static IDBStorageEnabled: boolean;
  27842. /**
  27843. * Gets a boolean indicating if scene must be saved in the database
  27844. */
  27845. readonly enableSceneOffline: boolean;
  27846. /**
  27847. * Gets a boolean indicating if textures must be saved in the database
  27848. */
  27849. readonly enableTexturesOffline: boolean;
  27850. /**
  27851. * Creates a new Database
  27852. * @param urlToScene defines the url to load the scene
  27853. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27854. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27855. */
  27856. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27857. private static _ParseURL;
  27858. private static _ReturnFullUrlLocation;
  27859. private _checkManifestFile();
  27860. /**
  27861. * Open the database and make it available
  27862. * @param successCallback defines the callback to call on success
  27863. * @param errorCallback defines the callback to call on error
  27864. */
  27865. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27866. /**
  27867. * Loads an image from the database
  27868. * @param url defines the url to load from
  27869. * @param image defines the target DOM image
  27870. */
  27871. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27872. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27873. private _saveImageIntoDBAsync(url, image);
  27874. private _checkVersionFromDB(url, versionLoaded);
  27875. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27876. private _saveVersionIntoDBAsync(url, callback);
  27877. /**
  27878. * Loads a file from database
  27879. * @param url defines the URL to load from
  27880. * @param sceneLoaded defines a callback to call on success
  27881. * @param progressCallBack defines a callback to call when progress changed
  27882. * @param errorCallback defines a callback to call on error
  27883. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27884. */
  27885. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27886. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27887. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27888. }
  27889. }
  27890. declare module BABYLON {
  27891. interface DDSInfo {
  27892. width: number;
  27893. height: number;
  27894. mipmapCount: number;
  27895. isFourCC: boolean;
  27896. isRGB: boolean;
  27897. isLuminance: boolean;
  27898. isCube: boolean;
  27899. isCompressed: boolean;
  27900. dxgiFormat: number;
  27901. textureType: number;
  27902. /** Sphericle polynomial created for the dds texture */
  27903. sphericalPolynomial?: SphericalPolynomial;
  27904. }
  27905. class DDSTools {
  27906. static StoreLODInAlphaChannel: boolean;
  27907. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27908. private static _FloatView;
  27909. private static _Int32View;
  27910. private static _ToHalfFloat(value);
  27911. private static _FromHalfFloat(value);
  27912. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27913. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27914. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27915. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27916. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27917. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27918. private static _ExtractLongWordOrder(value);
  27919. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27920. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27921. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27922. }
  27923. }
  27924. declare module BABYLON {
  27925. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27926. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27927. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27928. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27929. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27930. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27931. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27932. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27933. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27934. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27935. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27936. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27937. /**
  27938. * Decorator used to define property that can be serialized as reference to a camera
  27939. * @param sourceName defines the name of the property to decorate
  27940. */
  27941. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27942. class SerializationHelper {
  27943. static Serialize<T>(entity: T, serializationObject?: any): any;
  27944. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27945. static Clone<T>(creationFunction: () => T, source: T): T;
  27946. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27947. }
  27948. }
  27949. declare module BABYLON {
  27950. /**
  27951. * Wrapper class for promise with external resolve and reject.
  27952. */
  27953. class Deferred<T> {
  27954. /**
  27955. * The promise associated with this deferred object.
  27956. */
  27957. readonly promise: Promise<T>;
  27958. private _resolve;
  27959. private _reject;
  27960. /**
  27961. * The resolve method of the promise associated with this deferred object.
  27962. */
  27963. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27964. /**
  27965. * The reject method of the promise associated with this deferred object.
  27966. */
  27967. readonly reject: (reason?: any) => void;
  27968. /**
  27969. * Constructor for this deferred object.
  27970. */
  27971. constructor();
  27972. }
  27973. }
  27974. declare module BABYLON {
  27975. class FilesInput {
  27976. static FilesToLoad: {
  27977. [key: string]: File;
  27978. };
  27979. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27980. private _engine;
  27981. private _currentScene;
  27982. private _sceneLoadedCallback;
  27983. private _progressCallback;
  27984. private _additionalRenderLoopLogicCallback;
  27985. private _textureLoadingCallback;
  27986. private _startingProcessingFilesCallback;
  27987. private _onReloadCallback;
  27988. private _errorCallback;
  27989. private _elementToMonitor;
  27990. private _sceneFileToLoad;
  27991. private _filesToLoad;
  27992. 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);
  27993. private _dragEnterHandler;
  27994. private _dragOverHandler;
  27995. private _dropHandler;
  27996. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27997. dispose(): void;
  27998. private renderFunction();
  27999. private drag(e);
  28000. private drop(eventDrop);
  28001. private _traverseFolder(folder, files, remaining, callback);
  28002. private _processFiles(files);
  28003. loadFiles(event: any): void;
  28004. private _processReload();
  28005. reload(): void;
  28006. }
  28007. }
  28008. declare module BABYLON {
  28009. /**
  28010. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28011. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28012. */
  28013. class KhronosTextureContainer {
  28014. arrayBuffer: any;
  28015. static HEADER_LEN: number;
  28016. static COMPRESSED_2D: number;
  28017. static COMPRESSED_3D: number;
  28018. static TEX_2D: number;
  28019. static TEX_3D: number;
  28020. glType: number;
  28021. glTypeSize: number;
  28022. glFormat: number;
  28023. glInternalFormat: number;
  28024. glBaseInternalFormat: number;
  28025. pixelWidth: number;
  28026. pixelHeight: number;
  28027. pixelDepth: number;
  28028. numberOfArrayElements: number;
  28029. numberOfFaces: number;
  28030. numberOfMipmapLevels: number;
  28031. bytesOfKeyValueData: number;
  28032. loadType: number;
  28033. /**
  28034. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  28035. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  28036. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  28037. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  28038. */
  28039. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  28040. switchEndainness(val: number): number;
  28041. /**
  28042. * It is assumed that the texture has already been created & is currently bound
  28043. */
  28044. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  28045. private _upload2DCompressedLevels(gl, loadMipmaps);
  28046. }
  28047. }
  28048. declare module BABYLON {
  28049. /**
  28050. * A class serves as a medium between the observable and its observers
  28051. */
  28052. class EventState {
  28053. /**
  28054. * Create a new EventState
  28055. * @param mask defines the mask associated with this state
  28056. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28057. * @param target defines the original target of the state
  28058. * @param currentTarget defines the current target of the state
  28059. */
  28060. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  28061. /**
  28062. * Initialize the current event state
  28063. * @param mask defines the mask associated with this state
  28064. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28065. * @param target defines the original target of the state
  28066. * @param currentTarget defines the current target of the state
  28067. * @returns the current event state
  28068. */
  28069. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  28070. /**
  28071. * An Observer can set this property to true to prevent subsequent observers of being notified
  28072. */
  28073. skipNextObservers: boolean;
  28074. /**
  28075. * Get the mask value that were used to trigger the event corresponding to this EventState object
  28076. */
  28077. mask: number;
  28078. /**
  28079. * The object that originally notified the event
  28080. */
  28081. target?: any;
  28082. /**
  28083. * The current object in the bubbling phase
  28084. */
  28085. currentTarget?: any;
  28086. /**
  28087. * This will be populated with the return value of the last function that was executed.
  28088. * If it is the first function in the callback chain it will be the event data.
  28089. */
  28090. lastReturnValue?: any;
  28091. }
  28092. /**
  28093. * Represent an Observer registered to a given Observable object.
  28094. */
  28095. class Observer<T> {
  28096. /**
  28097. * Defines the callback to call when the observer is notified
  28098. */
  28099. callback: (eventData: T, eventState: EventState) => void;
  28100. /**
  28101. * Defines the mask of the observer (used to filter notifications)
  28102. */
  28103. mask: number;
  28104. /**
  28105. * Defines the current scope used to restore the JS context
  28106. */
  28107. scope: any;
  28108. /** @hidden */
  28109. _willBeUnregistered: boolean;
  28110. /**
  28111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  28112. */
  28113. unregisterOnNextCall: boolean;
  28114. /**
  28115. * Creates a new observer
  28116. * @param callback defines the callback to call when the observer is notified
  28117. * @param mask defines the mask of the observer (used to filter notifications)
  28118. * @param scope defines the current scope used to restore the JS context
  28119. */
  28120. constructor(
  28121. /**
  28122. * Defines the callback to call when the observer is notified
  28123. */
  28124. callback: (eventData: T, eventState: EventState) => void,
  28125. /**
  28126. * Defines the mask of the observer (used to filter notifications)
  28127. */
  28128. mask: number,
  28129. /**
  28130. * Defines the current scope used to restore the JS context
  28131. */
  28132. scope?: any);
  28133. }
  28134. /**
  28135. * Represent a list of observers registered to multiple Observables object.
  28136. */
  28137. class MultiObserver<T> {
  28138. private _observers;
  28139. private _observables;
  28140. /**
  28141. * Release associated resources
  28142. */
  28143. dispose(): void;
  28144. /**
  28145. * Raise a callback when one of the observable will notify
  28146. * @param observables defines a list of observables to watch
  28147. * @param callback defines the callback to call on notification
  28148. * @param mask defines the mask used to filter notifications
  28149. * @param scope defines the current scope used to restore the JS context
  28150. * @returns the new MultiObserver
  28151. */
  28152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  28153. }
  28154. /**
  28155. * The Observable class is a simple implementation of the Observable pattern.
  28156. *
  28157. * 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.
  28158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  28159. * 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).
  28160. * 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.
  28161. */
  28162. class Observable<T> {
  28163. private _observers;
  28164. private _eventState;
  28165. private _onObserverAdded;
  28166. /**
  28167. * Creates a new observable
  28168. * @param onObserverAdded defines a callback to call when a new observer is added
  28169. */
  28170. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  28171. /**
  28172. * Create a new Observer with the specified callback
  28173. * @param callback the callback that will be executed for that Observer
  28174. * @param mask the mask used to filter observers
  28175. * @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.
  28176. * @param scope optional scope for the callback to be called from
  28177. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  28178. * @returns the new observer created for the callback
  28179. */
  28180. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  28181. /**
  28182. * Create a new Observer with the specified callback and unregisters after the next notification
  28183. * @param callback the callback that will be executed for that Observer
  28184. * @returns the new observer created for the callback
  28185. */
  28186. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  28187. /**
  28188. * Remove an Observer from the Observable object
  28189. * @param observer the instance of the Observer to remove
  28190. * @returns false if it doesn't belong to this Observable
  28191. */
  28192. remove(observer: Nullable<Observer<T>>): boolean;
  28193. /**
  28194. * Remove a callback from the Observable object
  28195. * @param callback the callback to remove
  28196. * @param scope optional scope. If used only the callbacks with this scope will be removed
  28197. * @returns false if it doesn't belong to this Observable
  28198. */
  28199. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  28200. private _deferUnregister(observer);
  28201. /**
  28202. * Notify all Observers by calling their respective callback with the given data
  28203. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  28204. * @param eventData defines the data to send to all observers
  28205. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  28206. * @param target defines the original target of the state
  28207. * @param currentTarget defines the current target of the state
  28208. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  28209. */
  28210. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  28211. /**
  28212. * Calling this will execute each callback, expecting it to be a promise or return a value.
  28213. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  28214. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  28215. * and it is crucial that all callbacks will be executed.
  28216. * The order of the callbacks is kept, callbacks are not executed parallel.
  28217. *
  28218. * @param eventData The data to be sent to each callback
  28219. * @param mask is used to filter observers defaults to -1
  28220. * @param target defines the callback target (see EventState)
  28221. * @param currentTarget defines he current object in the bubbling phase
  28222. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  28223. */
  28224. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  28225. /**
  28226. * Notify a specific observer
  28227. * @param observer defines the observer to notify
  28228. * @param eventData defines the data to be sent to each callback
  28229. * @param mask is used to filter observers defaults to -1
  28230. */
  28231. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  28232. /**
  28233. * Gets a boolean indicating if the observable has at least one observer
  28234. * @returns true is the Observable has at least one Observer registered
  28235. */
  28236. hasObservers(): boolean;
  28237. /**
  28238. * Clear the list of observers
  28239. */
  28240. clear(): void;
  28241. /**
  28242. * Clone the current observable
  28243. * @returns a new observable
  28244. */
  28245. clone(): Observable<T>;
  28246. /**
  28247. * Does this observable handles observer registered with a given mask
  28248. * @param mask defines the mask to be tested
  28249. * @return whether or not one observer registered with the given mask is handeled
  28250. **/
  28251. hasSpecificMask(mask?: number): boolean;
  28252. }
  28253. }
  28254. declare module BABYLON {
  28255. /**
  28256. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  28257. */
  28258. class PerformanceMonitor {
  28259. private _enabled;
  28260. private _rollingFrameTime;
  28261. private _lastFrameTimeMs;
  28262. /**
  28263. * constructor
  28264. * @param frameSampleSize The number of samples required to saturate the sliding window
  28265. */
  28266. constructor(frameSampleSize?: number);
  28267. /**
  28268. * Samples current frame
  28269. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  28270. */
  28271. sampleFrame(timeMs?: number): void;
  28272. /**
  28273. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28274. * @return Average frame time in milliseconds
  28275. */
  28276. readonly averageFrameTime: number;
  28277. /**
  28278. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28279. * @return Frame time variance in milliseconds squared
  28280. */
  28281. readonly averageFrameTimeVariance: number;
  28282. /**
  28283. * Returns the frame time of the most recent frame
  28284. * @return Frame time in milliseconds
  28285. */
  28286. readonly instantaneousFrameTime: number;
  28287. /**
  28288. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  28289. * @return Framerate in frames per second
  28290. */
  28291. readonly averageFPS: number;
  28292. /**
  28293. * Returns the average framerate in frames per second using the most recent frame time
  28294. * @return Framerate in frames per second
  28295. */
  28296. readonly instantaneousFPS: number;
  28297. /**
  28298. * Returns true if enough samples have been taken to completely fill the sliding window
  28299. * @return true if saturated
  28300. */
  28301. readonly isSaturated: boolean;
  28302. /**
  28303. * Enables contributions to the sliding window sample set
  28304. */
  28305. enable(): void;
  28306. /**
  28307. * Disables contributions to the sliding window sample set
  28308. * Samples will not be interpolated over the disabled period
  28309. */
  28310. disable(): void;
  28311. /**
  28312. * Returns true if sampling is enabled
  28313. * @return true if enabled
  28314. */
  28315. readonly isEnabled: boolean;
  28316. /**
  28317. * Resets performance monitor
  28318. */
  28319. reset(): void;
  28320. }
  28321. /**
  28322. * RollingAverage
  28323. *
  28324. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  28325. */
  28326. class RollingAverage {
  28327. /**
  28328. * Current average
  28329. */
  28330. average: number;
  28331. /**
  28332. * Current variance
  28333. */
  28334. variance: number;
  28335. protected _samples: Array<number>;
  28336. protected _sampleCount: number;
  28337. protected _pos: number;
  28338. protected _m2: number;
  28339. /**
  28340. * constructor
  28341. * @param length The number of samples required to saturate the sliding window
  28342. */
  28343. constructor(length: number);
  28344. /**
  28345. * Adds a sample to the sample set
  28346. * @param v The sample value
  28347. */
  28348. add(v: number): void;
  28349. /**
  28350. * Returns previously added values or null if outside of history or outside the sliding window domain
  28351. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  28352. * @return Value previously recorded with add() or null if outside of range
  28353. */
  28354. history(i: number): number;
  28355. /**
  28356. * Returns true if enough samples have been taken to completely fill the sliding window
  28357. * @return true if sample-set saturated
  28358. */
  28359. isSaturated(): boolean;
  28360. /**
  28361. * Resets the rolling average (equivalent to 0 samples taken so far)
  28362. */
  28363. reset(): void;
  28364. /**
  28365. * Wraps a value around the sample range boundaries
  28366. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  28367. * @return Wrapped position in sample range
  28368. */
  28369. protected _wrapPosition(i: number): number;
  28370. }
  28371. }
  28372. declare module BABYLON {
  28373. /**
  28374. * Helper class that provides a small promise polyfill
  28375. */
  28376. class PromisePolyfill {
  28377. /**
  28378. * Static function used to check if the polyfill is required
  28379. * If this is the case then the function will inject the polyfill to window.Promise
  28380. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  28381. */
  28382. static Apply(force?: boolean): void;
  28383. }
  28384. }
  28385. declare module BABYLON {
  28386. /**
  28387. * Defines the root class used to create scene optimization to use with SceneOptimizer
  28388. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28389. */
  28390. class SceneOptimization {
  28391. /**
  28392. * Defines the priority of this optimization (0 by default which means first in the list)
  28393. */
  28394. priority: number;
  28395. /**
  28396. * Gets a string describing the action executed by the current optimization
  28397. * @returns description string
  28398. */
  28399. getDescription(): string;
  28400. /**
  28401. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28402. * @param scene defines the current scene where to apply this optimization
  28403. * @param optimizer defines the current optimizer
  28404. * @returns true if everything that can be done was applied
  28405. */
  28406. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28407. /**
  28408. * Creates the SceneOptimization object
  28409. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28410. * @param desc defines the description associated with the optimization
  28411. */
  28412. constructor(
  28413. /**
  28414. * Defines the priority of this optimization (0 by default which means first in the list)
  28415. */
  28416. priority?: number);
  28417. }
  28418. /**
  28419. * Defines an optimization used to reduce the size of render target textures
  28420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28421. */
  28422. class TextureOptimization extends SceneOptimization {
  28423. /**
  28424. * Defines the priority of this optimization (0 by default which means first in the list)
  28425. */
  28426. priority: number;
  28427. /**
  28428. * 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
  28429. */
  28430. maximumSize: number;
  28431. /**
  28432. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28433. */
  28434. step: number;
  28435. /**
  28436. * Gets a string describing the action executed by the current optimization
  28437. * @returns description string
  28438. */
  28439. getDescription(): string;
  28440. /**
  28441. * Creates the TextureOptimization object
  28442. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28443. * @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
  28444. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28445. */
  28446. constructor(
  28447. /**
  28448. * Defines the priority of this optimization (0 by default which means first in the list)
  28449. */
  28450. priority?: number,
  28451. /**
  28452. * 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
  28453. */
  28454. maximumSize?: number,
  28455. /**
  28456. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28457. */
  28458. step?: number);
  28459. /**
  28460. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28461. * @param scene defines the current scene where to apply this optimization
  28462. * @param optimizer defines the current optimizer
  28463. * @returns true if everything that can be done was applied
  28464. */
  28465. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28466. }
  28467. /**
  28468. * Defines an optimization used to increase or decrease the rendering resolution
  28469. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28470. */
  28471. class HardwareScalingOptimization extends SceneOptimization {
  28472. /**
  28473. * Defines the priority of this optimization (0 by default which means first in the list)
  28474. */
  28475. priority: number;
  28476. /**
  28477. * Defines the maximum scale to use (2 by default)
  28478. */
  28479. maximumScale: number;
  28480. /**
  28481. * Defines the step to use between two passes (0.5 by default)
  28482. */
  28483. step: number;
  28484. private _currentScale;
  28485. private _directionOffset;
  28486. /**
  28487. * Gets a string describing the action executed by the current optimization
  28488. * @return description string
  28489. */
  28490. getDescription(): string;
  28491. /**
  28492. * Creates the HardwareScalingOptimization object
  28493. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28494. * @param maximumScale defines the maximum scale to use (2 by default)
  28495. * @param step defines the step to use between two passes (0.5 by default)
  28496. */
  28497. constructor(
  28498. /**
  28499. * Defines the priority of this optimization (0 by default which means first in the list)
  28500. */
  28501. priority?: number,
  28502. /**
  28503. * Defines the maximum scale to use (2 by default)
  28504. */
  28505. maximumScale?: number,
  28506. /**
  28507. * Defines the step to use between two passes (0.5 by default)
  28508. */
  28509. step?: number);
  28510. /**
  28511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28512. * @param scene defines the current scene where to apply this optimization
  28513. * @param optimizer defines the current optimizer
  28514. * @returns true if everything that can be done was applied
  28515. */
  28516. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28517. }
  28518. /**
  28519. * Defines an optimization used to remove shadows
  28520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28521. */
  28522. class ShadowsOptimization extends SceneOptimization {
  28523. /**
  28524. * Gets a string describing the action executed by the current optimization
  28525. * @return description string
  28526. */
  28527. getDescription(): string;
  28528. /**
  28529. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28530. * @param scene defines the current scene where to apply this optimization
  28531. * @param optimizer defines the current optimizer
  28532. * @returns true if everything that can be done was applied
  28533. */
  28534. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28535. }
  28536. /**
  28537. * Defines an optimization used to turn post-processes off
  28538. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28539. */
  28540. class PostProcessesOptimization extends SceneOptimization {
  28541. /**
  28542. * Gets a string describing the action executed by the current optimization
  28543. * @return description string
  28544. */
  28545. getDescription(): string;
  28546. /**
  28547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28548. * @param scene defines the current scene where to apply this optimization
  28549. * @param optimizer defines the current optimizer
  28550. * @returns true if everything that can be done was applied
  28551. */
  28552. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28553. }
  28554. /**
  28555. * Defines an optimization used to turn lens flares off
  28556. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28557. */
  28558. class LensFlaresOptimization extends SceneOptimization {
  28559. /**
  28560. * Gets a string describing the action executed by the current optimization
  28561. * @return description string
  28562. */
  28563. getDescription(): string;
  28564. /**
  28565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28566. * @param scene defines the current scene where to apply this optimization
  28567. * @param optimizer defines the current optimizer
  28568. * @returns true if everything that can be done was applied
  28569. */
  28570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28571. }
  28572. /**
  28573. * Defines an optimization based on user defined callback.
  28574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28575. */
  28576. class CustomOptimization extends SceneOptimization {
  28577. /**
  28578. * Callback called to apply the custom optimization.
  28579. */
  28580. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  28581. /**
  28582. * Callback called to get custom description
  28583. */
  28584. onGetDescription: () => string;
  28585. /**
  28586. * Gets a string describing the action executed by the current optimization
  28587. * @returns description string
  28588. */
  28589. getDescription(): string;
  28590. /**
  28591. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28592. * @param scene defines the current scene where to apply this optimization
  28593. * @param optimizer defines the current optimizer
  28594. * @returns true if everything that can be done was applied
  28595. */
  28596. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28597. }
  28598. /**
  28599. * Defines an optimization used to turn particles off
  28600. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28601. */
  28602. class ParticlesOptimization extends SceneOptimization {
  28603. /**
  28604. * Gets a string describing the action executed by the current optimization
  28605. * @return description string
  28606. */
  28607. getDescription(): string;
  28608. /**
  28609. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28610. * @param scene defines the current scene where to apply this optimization
  28611. * @param optimizer defines the current optimizer
  28612. * @returns true if everything that can be done was applied
  28613. */
  28614. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28615. }
  28616. /**
  28617. * Defines an optimization used to turn render targets off
  28618. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28619. */
  28620. class RenderTargetsOptimization extends SceneOptimization {
  28621. /**
  28622. * Gets a string describing the action executed by the current optimization
  28623. * @return description string
  28624. */
  28625. getDescription(): string;
  28626. /**
  28627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28628. * @param scene defines the current scene where to apply this optimization
  28629. * @param optimizer defines the current optimizer
  28630. * @returns true if everything that can be done was applied
  28631. */
  28632. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28633. }
  28634. /**
  28635. * Defines an optimization used to merge meshes with compatible materials
  28636. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28637. */
  28638. class MergeMeshesOptimization extends SceneOptimization {
  28639. private static _UpdateSelectionTree;
  28640. /**
  28641. * Gets or sets a boolean which defines if optimization octree has to be updated
  28642. */
  28643. /**
  28644. * Gets or sets a boolean which defines if optimization octree has to be updated
  28645. */
  28646. static UpdateSelectionTree: boolean;
  28647. /**
  28648. * Gets a string describing the action executed by the current optimization
  28649. * @return description string
  28650. */
  28651. getDescription(): string;
  28652. private _canBeMerged;
  28653. /**
  28654. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28655. * @param scene defines the current scene where to apply this optimization
  28656. * @param optimizer defines the current optimizer
  28657. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28658. * @returns true if everything that can be done was applied
  28659. */
  28660. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28661. }
  28662. /**
  28663. * Defines a list of options used by SceneOptimizer
  28664. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28665. */
  28666. class SceneOptimizerOptions {
  28667. /**
  28668. * Defines the target frame rate to reach (60 by default)
  28669. */
  28670. targetFrameRate: number;
  28671. /**
  28672. * Defines the interval between two checkes (2000ms by default)
  28673. */
  28674. trackerDuration: number;
  28675. /**
  28676. * Gets the list of optimizations to apply
  28677. */
  28678. optimizations: SceneOptimization[];
  28679. /**
  28680. * Creates a new list of options used by SceneOptimizer
  28681. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28682. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28683. */
  28684. constructor(
  28685. /**
  28686. * Defines the target frame rate to reach (60 by default)
  28687. */
  28688. targetFrameRate?: number,
  28689. /**
  28690. * Defines the interval between two checkes (2000ms by default)
  28691. */
  28692. trackerDuration?: number);
  28693. /**
  28694. * Add a new optimization
  28695. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28696. * @returns the current SceneOptimizerOptions
  28697. */
  28698. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28699. /**
  28700. * Add a new custom optimization
  28701. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28702. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28703. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28704. * @returns the current SceneOptimizerOptions
  28705. */
  28706. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28707. /**
  28708. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28709. * @param targetFrameRate defines the target frame rate (60 by default)
  28710. * @returns a SceneOptimizerOptions object
  28711. */
  28712. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28713. /**
  28714. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28715. * @param targetFrameRate defines the target frame rate (60 by default)
  28716. * @returns a SceneOptimizerOptions object
  28717. */
  28718. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28719. /**
  28720. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28721. * @param targetFrameRate defines the target frame rate (60 by default)
  28722. * @returns a SceneOptimizerOptions object
  28723. */
  28724. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28725. }
  28726. /**
  28727. * Class used to run optimizations in order to reach a target frame rate
  28728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28729. */
  28730. class SceneOptimizer implements IDisposable {
  28731. private _isRunning;
  28732. private _options;
  28733. private _scene;
  28734. private _currentPriorityLevel;
  28735. private _targetFrameRate;
  28736. private _trackerDuration;
  28737. private _currentFrameRate;
  28738. private _sceneDisposeObserver;
  28739. private _improvementMode;
  28740. /**
  28741. * Defines an observable called when the optimizer reaches the target frame rate
  28742. */
  28743. onSuccessObservable: Observable<SceneOptimizer>;
  28744. /**
  28745. * Defines an observable called when the optimizer enables an optimization
  28746. */
  28747. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28748. /**
  28749. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28750. */
  28751. onFailureObservable: Observable<SceneOptimizer>;
  28752. /**
  28753. * Gets a boolean indicating if the optimizer is in improvement mode
  28754. */
  28755. readonly isInImprovementMode: boolean;
  28756. /**
  28757. * Gets the current priority level (0 at start)
  28758. */
  28759. readonly currentPriorityLevel: number;
  28760. /**
  28761. * Gets the current frame rate checked by the SceneOptimizer
  28762. */
  28763. readonly currentFrameRate: number;
  28764. /**
  28765. * Gets or sets the current target frame rate (60 by default)
  28766. */
  28767. /**
  28768. * Gets or sets the current target frame rate (60 by default)
  28769. */
  28770. targetFrameRate: number;
  28771. /**
  28772. * Gets or sets the current interval between two checks (every 2000ms by default)
  28773. */
  28774. /**
  28775. * Gets or sets the current interval between two checks (every 2000ms by default)
  28776. */
  28777. trackerDuration: number;
  28778. /**
  28779. * Gets the list of active optimizations
  28780. */
  28781. readonly optimizations: SceneOptimization[];
  28782. /**
  28783. * Creates a new SceneOptimizer
  28784. * @param scene defines the scene to work on
  28785. * @param options defines the options to use with the SceneOptimizer
  28786. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28787. * @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)
  28788. */
  28789. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28790. /**
  28791. * Stops the current optimizer
  28792. */
  28793. stop(): void;
  28794. /**
  28795. * Reset the optimizer to initial step (current priority level = 0)
  28796. */
  28797. reset(): void;
  28798. /**
  28799. * Start the optimizer. By default it will try to reach a specific framerate
  28800. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28801. */
  28802. start(): void;
  28803. private _checkCurrentState();
  28804. /**
  28805. * Release all resources
  28806. */
  28807. dispose(): void;
  28808. /**
  28809. * Helper function to create a SceneOptimizer with one single line of code
  28810. * @param scene defines the scene to work on
  28811. * @param options defines the options to use with the SceneOptimizer
  28812. * @param onSuccess defines a callback to call on success
  28813. * @param onFailure defines a callback to call on failure
  28814. * @returns the new SceneOptimizer object
  28815. */
  28816. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28817. }
  28818. }
  28819. declare module BABYLON {
  28820. class SceneSerializer {
  28821. static ClearCache(): void;
  28822. static Serialize(scene: Scene): any;
  28823. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28824. }
  28825. }
  28826. declare module BABYLON {
  28827. class SmartArray<T> {
  28828. data: Array<T>;
  28829. length: number;
  28830. protected _id: number;
  28831. [index: number]: T;
  28832. constructor(capacity: number);
  28833. push(value: T): void;
  28834. forEach(func: (content: T) => void): void;
  28835. sort(compareFn: (a: T, b: T) => number): void;
  28836. reset(): void;
  28837. dispose(): void;
  28838. concat(array: any): void;
  28839. indexOf(value: T): number;
  28840. contains(value: T): boolean;
  28841. private static _GlobalId;
  28842. }
  28843. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28844. private _duplicateId;
  28845. [index: number]: T;
  28846. push(value: T): void;
  28847. pushNoDuplicate(value: T): boolean;
  28848. reset(): void;
  28849. concatWithNoDuplicate(array: any): void;
  28850. }
  28851. }
  28852. declare module BABYLON {
  28853. /**
  28854. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28855. * The underlying implementation relies on an associative array to ensure the best performances.
  28856. * The value can be anything including 'null' but except 'undefined'
  28857. */
  28858. class StringDictionary<T> {
  28859. /**
  28860. * This will clear this dictionary and copy the content from the 'source' one.
  28861. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28862. * @param source the dictionary to take the content from and copy to this dictionary
  28863. */
  28864. copyFrom(source: StringDictionary<T>): void;
  28865. /**
  28866. * Get a value based from its key
  28867. * @param key the given key to get the matching value from
  28868. * @return the value if found, otherwise undefined is returned
  28869. */
  28870. get(key: string): T | undefined;
  28871. /**
  28872. * Get a value from its key or add it if it doesn't exist.
  28873. * This method will ensure you that a given key/data will be present in the dictionary.
  28874. * @param key the given key to get the matching value from
  28875. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28876. * The factory will only be invoked if there's no data for the given key.
  28877. * @return the value corresponding to the key.
  28878. */
  28879. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28880. /**
  28881. * Get a value from its key if present in the dictionary otherwise add it
  28882. * @param key the key to get the value from
  28883. * @param val if there's no such key/value pair in the dictionary add it with this value
  28884. * @return the value corresponding to the key
  28885. */
  28886. getOrAdd(key: string, val: T): T;
  28887. /**
  28888. * Check if there's a given key in the dictionary
  28889. * @param key the key to check for
  28890. * @return true if the key is present, false otherwise
  28891. */
  28892. contains(key: string): boolean;
  28893. /**
  28894. * Add a new key and its corresponding value
  28895. * @param key the key to add
  28896. * @param value the value corresponding to the key
  28897. * @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
  28898. */
  28899. add(key: string, value: T): boolean;
  28900. set(key: string, value: T): boolean;
  28901. /**
  28902. * Get the element of the given key and remove it from the dictionary
  28903. * @param key
  28904. */
  28905. getAndRemove(key: string): Nullable<T>;
  28906. /**
  28907. * Remove a key/value from the dictionary.
  28908. * @param key the key to remove
  28909. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28910. */
  28911. remove(key: string): boolean;
  28912. /**
  28913. * Clear the whole content of the dictionary
  28914. */
  28915. clear(): void;
  28916. readonly count: number;
  28917. /**
  28918. * Execute a callback on each key/val of the dictionary.
  28919. * Note that you can remove any element in this dictionary in the callback implementation
  28920. * @param callback the callback to execute on a given key/value pair
  28921. */
  28922. forEach(callback: (key: string, val: T) => void): void;
  28923. /**
  28924. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28925. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28926. * Note that you can remove any element in this dictionary in the callback implementation
  28927. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28928. */
  28929. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28930. private _count;
  28931. private _data;
  28932. }
  28933. }
  28934. declare module BABYLON {
  28935. class Tags {
  28936. static EnableFor(obj: any): void;
  28937. static DisableFor(obj: any): void;
  28938. static HasTags(obj: any): boolean;
  28939. static GetTags(obj: any, asString?: boolean): any;
  28940. static AddTagsTo(obj: any, tagsString: string): void;
  28941. static _AddTagTo(obj: any, tag: string): void;
  28942. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28943. static _RemoveTagFrom(obj: any, tag: string): void;
  28944. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28945. }
  28946. }
  28947. declare module BABYLON {
  28948. class TextureTools {
  28949. /**
  28950. * Uses the GPU to create a copy texture rescaled at a given size
  28951. * @param texture Texture to copy from
  28952. * @param width Desired width
  28953. * @param height Desired height
  28954. * @return Generated texture
  28955. */
  28956. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28957. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28958. private static _environmentBRDFBase64Texture;
  28959. }
  28960. }
  28961. declare module BABYLON {
  28962. class TGATools {
  28963. private static _TYPE_INDEXED;
  28964. private static _TYPE_RGB;
  28965. private static _TYPE_GREY;
  28966. private static _TYPE_RLE_INDEXED;
  28967. private static _TYPE_RLE_RGB;
  28968. private static _TYPE_RLE_GREY;
  28969. private static _ORIGIN_MASK;
  28970. private static _ORIGIN_SHIFT;
  28971. private static _ORIGIN_BL;
  28972. private static _ORIGIN_BR;
  28973. private static _ORIGIN_UL;
  28974. private static _ORIGIN_UR;
  28975. static GetTGAHeader(data: Uint8Array): any;
  28976. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28977. 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;
  28978. 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;
  28979. 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;
  28980. 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;
  28981. 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;
  28982. 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;
  28983. }
  28984. }
  28985. declare module BABYLON {
  28986. interface IAnimatable {
  28987. animations: Array<Animation>;
  28988. }
  28989. class LoadFileError extends Error {
  28990. request: XMLHttpRequest | undefined;
  28991. private static _setPrototypeOf;
  28992. constructor(message: string, request?: XMLHttpRequest | undefined);
  28993. }
  28994. class RetryStrategy {
  28995. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28996. }
  28997. interface IFileRequest {
  28998. /**
  28999. * Raised when the request is complete (success or error).
  29000. */
  29001. onCompleteObservable: Observable<IFileRequest>;
  29002. /**
  29003. * Aborts the request for a file.
  29004. */
  29005. abort: () => void;
  29006. }
  29007. class Tools {
  29008. static BaseUrl: string;
  29009. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29010. /**
  29011. * Default behaviour for cors in the application.
  29012. * It can be a string if the expected behavior is identical in the entire app.
  29013. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29014. */
  29015. static CorsBehavior: string | ((url: string | string[]) => string);
  29016. static UseFallbackTexture: boolean;
  29017. /**
  29018. * Use this object to register external classes like custom textures or material
  29019. * to allow the laoders to instantiate them
  29020. */
  29021. static RegisteredExternalClasses: {
  29022. [key: string]: Object;
  29023. };
  29024. static fallbackTexture: string;
  29025. /**
  29026. * Interpolates between a and b via alpha
  29027. * @param a The lower value (returned when alpha = 0)
  29028. * @param b The upper value (returned when alpha = 1)
  29029. * @param alpha The interpolation-factor
  29030. * @return The mixed value
  29031. */
  29032. static Mix(a: number, b: number, alpha: number): number;
  29033. static Instantiate(className: string): any;
  29034. /**
  29035. * Provides a slice function that will work even on IE
  29036. * @param data defines the array to slice
  29037. * @param start defines the start of the data (optional)
  29038. * @param end defines the end of the data (optional)
  29039. * @returns the new sliced array
  29040. */
  29041. static Slice<T>(data: T, start?: number, end?: number): T;
  29042. static SetImmediate(action: () => void): void;
  29043. static IsExponentOfTwo(value: number): boolean;
  29044. private static _tmpFloatArray;
  29045. /**
  29046. * Returns the nearest 32-bit single precision float representation of a Number
  29047. * @param value A Number. If the parameter is of a different type, it will get converted
  29048. * to a number or to NaN if it cannot be converted
  29049. * @returns number
  29050. */
  29051. static FloatRound(value: number): number;
  29052. /**
  29053. * Find the next highest power of two.
  29054. * @param x Number to start search from.
  29055. * @return Next highest power of two.
  29056. */
  29057. static CeilingPOT(x: number): number;
  29058. /**
  29059. * Find the next lowest power of two.
  29060. * @param x Number to start search from.
  29061. * @return Next lowest power of two.
  29062. */
  29063. static FloorPOT(x: number): number;
  29064. /**
  29065. * Find the nearest power of two.
  29066. * @param x Number to start search from.
  29067. * @return Next nearest power of two.
  29068. */
  29069. static NearestPOT(x: number): number;
  29070. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29071. static GetFilename(path: string): string;
  29072. /**
  29073. * Extracts the "folder" part of a path (everything before the filename).
  29074. * @param uri The URI to extract the info from
  29075. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29076. * @returns The "folder" part of the path
  29077. */
  29078. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29079. static GetDOMTextContent(element: HTMLElement): string;
  29080. static ToDegrees(angle: number): number;
  29081. static ToRadians(angle: number): number;
  29082. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29083. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29084. minimum: Vector3;
  29085. maximum: Vector3;
  29086. };
  29087. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29088. minimum: Vector3;
  29089. maximum: Vector3;
  29090. };
  29091. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  29092. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  29093. minimum: Vector2;
  29094. maximum: Vector2;
  29095. };
  29096. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29097. static GetPointerPrefix(): string;
  29098. /**
  29099. * @param func - the function to be called
  29100. * @param requester - the object that will request the next frame. Falls back to window.
  29101. */
  29102. static QueueNewFrame(func: () => void, requester?: any): number;
  29103. static RequestFullscreen(element: HTMLElement): void;
  29104. static ExitFullscreen(): void;
  29105. static SetCorsBehavior(url: string | string[], element: {
  29106. crossOrigin: string | null;
  29107. }): void;
  29108. static CleanUrl(url: string): string;
  29109. static PreprocessUrl: (url: string) => string;
  29110. /**
  29111. * Loads an image as an HTMLImageElement.
  29112. * @param input url string, ArrayBuffer, or Blob to load
  29113. * @param onLoad callback called when the image successfully loads
  29114. * @param onError callback called when the image fails to load
  29115. * @param database database for caching
  29116. * @returns the HTMLImageElement of the loaded image
  29117. */
  29118. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  29119. 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;
  29120. /**
  29121. * Load a script (identified by an url). When the url returns, the
  29122. * content of this file is added into a new script element, attached to the DOM (body element)
  29123. */
  29124. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29125. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29126. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29127. static FileAsURL(content: string): string;
  29128. static Format(value: number, decimals?: number): string;
  29129. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29130. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29131. static IsEmpty(obj: any): boolean;
  29132. static RegisterTopRootEvents(events: {
  29133. name: string;
  29134. handler: Nullable<(e: FocusEvent) => any>;
  29135. }[]): void;
  29136. static UnregisterTopRootEvents(events: {
  29137. name: string;
  29138. handler: Nullable<(e: FocusEvent) => any>;
  29139. }[]): void;
  29140. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29141. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29142. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29143. /**
  29144. * Generates an image screenshot from the specified camera.
  29145. *
  29146. * @param engine The engine to use for rendering
  29147. * @param camera The camera to use for rendering
  29148. * @param size This parameter can be set to a single number or to an object with the
  29149. * following (optional) properties: precision, width, height. If a single number is passed,
  29150. * it will be used for both width and height. If an object is passed, the screenshot size
  29151. * will be derived from the parameters. The precision property is a multiplier allowing
  29152. * rendering at a higher or lower resolution.
  29153. * @param successCallback The callback receives a single parameter which contains the
  29154. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29155. * src parameter of an <img> to display it.
  29156. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29157. * Check your browser for supported MIME types.
  29158. * @param samples Texture samples (default: 1)
  29159. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29160. * @param fileName A name for for the downloaded file.
  29161. * @constructor
  29162. */
  29163. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29164. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  29165. /**
  29166. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29167. * Be aware Math.random() could cause collisions, but:
  29168. * "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"
  29169. */
  29170. static RandomId(): string;
  29171. /**
  29172. * Test if the given uri is a base64 string.
  29173. * @param uri The uri to test
  29174. * @return True if the uri is a base64 string or false otherwise.
  29175. */
  29176. static IsBase64(uri: string): boolean;
  29177. /**
  29178. * Decode the given base64 uri.
  29179. * @param uri The uri to decode
  29180. * @return The decoded base64 data.
  29181. */
  29182. static DecodeBase64(uri: string): ArrayBuffer;
  29183. private static _NoneLogLevel;
  29184. private static _MessageLogLevel;
  29185. private static _WarningLogLevel;
  29186. private static _ErrorLogLevel;
  29187. private static _LogCache;
  29188. static errorsCount: number;
  29189. static OnNewCacheEntry: (entry: string) => void;
  29190. static readonly NoneLogLevel: number;
  29191. static readonly MessageLogLevel: number;
  29192. static readonly WarningLogLevel: number;
  29193. static readonly ErrorLogLevel: number;
  29194. static readonly AllLogLevel: number;
  29195. private static _AddLogEntry(entry);
  29196. private static _FormatMessage(message);
  29197. private static _LogDisabled(message);
  29198. private static _LogEnabled(message);
  29199. private static _WarnDisabled(message);
  29200. private static _WarnEnabled(message);
  29201. private static _ErrorDisabled(message);
  29202. private static _ErrorEnabled(message);
  29203. static Log: (message: string) => void;
  29204. static Warn: (message: string) => void;
  29205. static Error: (message: string) => void;
  29206. static readonly LogCache: string;
  29207. static ClearLogCache(): void;
  29208. static LogLevels: number;
  29209. static IsWindowObjectExist(): boolean;
  29210. private static _PerformanceNoneLogLevel;
  29211. private static _PerformanceUserMarkLogLevel;
  29212. private static _PerformanceConsoleLogLevel;
  29213. private static _performance;
  29214. static readonly PerformanceNoneLogLevel: number;
  29215. static readonly PerformanceUserMarkLogLevel: number;
  29216. static readonly PerformanceConsoleLogLevel: number;
  29217. static PerformanceLogLevel: number;
  29218. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29219. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29220. static _StartUserMark(counterName: string, condition?: boolean): void;
  29221. static _EndUserMark(counterName: string, condition?: boolean): void;
  29222. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  29223. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  29224. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29225. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29226. static readonly Now: number;
  29227. /**
  29228. * This method will return the name of the class used to create the instance of the given object.
  29229. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29230. * @param object the object to get the class name from
  29231. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  29232. */
  29233. static GetClassName(object: any, isType?: boolean): string;
  29234. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29235. /**
  29236. * This method will return the name of the full name of the class, including its owning module (if any).
  29237. * 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).
  29238. * @param object the object to get the class name from
  29239. * @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.
  29240. */
  29241. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29242. /**
  29243. * 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.
  29244. * @param array
  29245. */
  29246. static arrayOrStringFeeder(array: any): (i: number) => number;
  29247. /**
  29248. * Compute the hashCode of a stream of number
  29249. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  29250. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  29251. * @return the hash code computed
  29252. */
  29253. static hashCodeFromStream(feeder: (index: number) => number): number;
  29254. /**
  29255. * Returns a promise that resolves after the given amount of time.
  29256. * @param delay Number of milliseconds to delay
  29257. * @returns Promise that resolves after the given amount of time
  29258. */
  29259. static DelayAsync(delay: number): Promise<void>;
  29260. }
  29261. /**
  29262. * This class is used to track a performance counter which is number based.
  29263. * The user has access to many properties which give statistics of different nature
  29264. *
  29265. * The implementer can track two kinds of Performance Counter: time and count
  29266. * 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.
  29267. * 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.
  29268. */
  29269. class PerfCounter {
  29270. static Enabled: boolean;
  29271. /**
  29272. * Returns the smallest value ever
  29273. */
  29274. readonly min: number;
  29275. /**
  29276. * Returns the biggest value ever
  29277. */
  29278. readonly max: number;
  29279. /**
  29280. * Returns the average value since the performance counter is running
  29281. */
  29282. readonly average: number;
  29283. /**
  29284. * Returns the average value of the last second the counter was monitored
  29285. */
  29286. readonly lastSecAverage: number;
  29287. /**
  29288. * Returns the current value
  29289. */
  29290. readonly current: number;
  29291. readonly total: number;
  29292. readonly count: number;
  29293. constructor();
  29294. /**
  29295. * Call this method to start monitoring a new frame.
  29296. * 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.
  29297. */
  29298. fetchNewFrame(): void;
  29299. /**
  29300. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29301. * @param newCount the count value to add to the monitored count
  29302. * @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.
  29303. */
  29304. addCount(newCount: number, fetchResult: boolean): void;
  29305. /**
  29306. * Start monitoring this performance counter
  29307. */
  29308. beginMonitoring(): void;
  29309. /**
  29310. * Compute the time lapsed since the previous beginMonitoring() call.
  29311. * @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
  29312. */
  29313. endMonitoring(newFrame?: boolean): void;
  29314. private _fetchResult();
  29315. private _startMonitoringTime;
  29316. private _min;
  29317. private _max;
  29318. private _average;
  29319. private _current;
  29320. private _totalValueCount;
  29321. private _totalAccumulated;
  29322. private _lastSecAverage;
  29323. private _lastSecAccumulated;
  29324. private _lastSecTime;
  29325. private _lastSecValueCount;
  29326. }
  29327. /**
  29328. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  29329. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  29330. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  29331. * @param name The name of the class, case should be preserved
  29332. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  29333. */
  29334. function className(name: string, module?: string): (target: Object) => void;
  29335. /**
  29336. * An implementation of a loop for asynchronous functions.
  29337. */
  29338. class AsyncLoop {
  29339. iterations: number;
  29340. private _fn;
  29341. private _successCallback;
  29342. index: number;
  29343. private _done;
  29344. /**
  29345. * Constroctor.
  29346. * @param iterations the number of iterations.
  29347. * @param _fn the function to run each iteration
  29348. * @param _successCallback the callback that will be called upon succesful execution
  29349. * @param offset starting offset.
  29350. */
  29351. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  29352. /**
  29353. * Execute the next iteration. Must be called after the last iteration was finished.
  29354. */
  29355. executeNext(): void;
  29356. /**
  29357. * Break the loop and run the success callback.
  29358. */
  29359. breakLoop(): void;
  29360. /**
  29361. * Helper function
  29362. */
  29363. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  29364. /**
  29365. * A for-loop that will run a given number of iterations synchronous and the rest async.
  29366. * @param iterations total number of iterations
  29367. * @param syncedIterations number of synchronous iterations in each async iteration.
  29368. * @param fn the function to call each iteration.
  29369. * @param callback a success call back that will be called when iterating stops.
  29370. * @param breakFunction a break condition (optional)
  29371. * @param timeout timeout settings for the setTimeout function. default - 0.
  29372. * @constructor
  29373. */
  29374. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  29375. }
  29376. }
  29377. declare module BABYLON {
  29378. /**
  29379. * Defines the potential axis of a Joystick
  29380. */
  29381. enum JoystickAxis {
  29382. /** X axis */
  29383. X = 0,
  29384. /** Y axis */
  29385. Y = 1,
  29386. /** Z axis */
  29387. Z = 2,
  29388. }
  29389. /**
  29390. * Class used to define virtual joystick (used in touch mode)
  29391. */
  29392. class VirtualJoystick {
  29393. /**
  29394. * Gets or sets a boolean indicating that left and right values must be inverted
  29395. */
  29396. reverseLeftRight: boolean;
  29397. /**
  29398. * Gets or sets a boolean indicating that up and down values must be inverted
  29399. */
  29400. reverseUpDown: boolean;
  29401. /**
  29402. * Gets the offset value for the position (ie. the change of the position value)
  29403. */
  29404. deltaPosition: Vector3;
  29405. /**
  29406. * Gets a boolean indicating if the virtual joystick was pressed
  29407. */
  29408. pressed: boolean;
  29409. private static _globalJoystickIndex;
  29410. private static vjCanvas;
  29411. private static vjCanvasContext;
  29412. private static vjCanvasWidth;
  29413. private static vjCanvasHeight;
  29414. private static halfWidth;
  29415. private _action;
  29416. private _axisTargetedByLeftAndRight;
  29417. private _axisTargetedByUpAndDown;
  29418. private _joystickSensibility;
  29419. private _inversedSensibility;
  29420. private _joystickPointerID;
  29421. private _joystickColor;
  29422. private _joystickPointerPos;
  29423. private _joystickPreviousPointerPos;
  29424. private _joystickPointerStartPos;
  29425. private _deltaJoystickVector;
  29426. private _leftJoystick;
  29427. private _touches;
  29428. private _onPointerDownHandlerRef;
  29429. private _onPointerMoveHandlerRef;
  29430. private _onPointerUpHandlerRef;
  29431. private _onResize;
  29432. /**
  29433. * Creates a new virtual joystick
  29434. * @param leftJoystick defines that the joystick is for left hand (false by default)
  29435. */
  29436. constructor(leftJoystick?: boolean);
  29437. /**
  29438. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  29439. * @param newJoystickSensibility defines the new sensibility
  29440. */
  29441. setJoystickSensibility(newJoystickSensibility: number): void;
  29442. private _onPointerDown(e);
  29443. private _onPointerMove(e);
  29444. private _onPointerUp(e);
  29445. /**
  29446. * Change the color of the virtual joystick
  29447. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  29448. */
  29449. setJoystickColor(newColor: string): void;
  29450. /**
  29451. * Defines a callback to call when the joystick is touched
  29452. * @param action defines the callback
  29453. */
  29454. setActionOnTouch(action: () => any): void;
  29455. /**
  29456. * Defines which axis you'd like to control for left & right
  29457. * @param axis defines the axis to use
  29458. */
  29459. setAxisForLeftRight(axis: JoystickAxis): void;
  29460. /**
  29461. * Defines which axis you'd like to control for up & down
  29462. * @param axis defines the axis to use
  29463. */
  29464. setAxisForUpDown(axis: JoystickAxis): void;
  29465. private _drawVirtualJoystick();
  29466. /**
  29467. * Release internal HTML canvas
  29468. */
  29469. releaseCanvas(): void;
  29470. }
  29471. }
  29472. declare module BABYLON {
  29473. /**
  29474. * Helper class to push actions to a pool of workers.
  29475. */
  29476. class WorkerPool implements IDisposable {
  29477. private _workerInfos;
  29478. private _pendingActions;
  29479. /**
  29480. * Constructor
  29481. * @param workers Array of workers to use for actions
  29482. */
  29483. constructor(workers: Array<Worker>);
  29484. /**
  29485. * Terminates all workers and clears any pending actions.
  29486. */
  29487. dispose(): void;
  29488. /**
  29489. * Pushes an action to the worker pool. If all the workers are active, the action will be
  29490. * pended until a worker has completed its action.
  29491. * @param action The action to perform. Call onComplete when the action is complete.
  29492. */
  29493. push(action: (worker: Worker, onComplete: () => void) => void): void;
  29494. private _execute(workerInfo, action);
  29495. }
  29496. }
  29497. declare module BABYLON {
  29498. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  29499. readonly name: string;
  29500. private _zoomStopsAnimation;
  29501. private _idleRotationSpeed;
  29502. private _idleRotationWaitTime;
  29503. private _idleRotationSpinupTime;
  29504. /**
  29505. * Gets the flag that indicates if user zooming should stop animation.
  29506. */
  29507. /**
  29508. * Sets the flag that indicates if user zooming should stop animation.
  29509. */
  29510. zoomStopsAnimation: boolean;
  29511. /**
  29512. * Gets the default speed at which the camera rotates around the model.
  29513. */
  29514. /**
  29515. * Sets the default speed at which the camera rotates around the model.
  29516. */
  29517. idleRotationSpeed: number;
  29518. /**
  29519. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  29520. */
  29521. /**
  29522. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  29523. */
  29524. idleRotationWaitTime: number;
  29525. /**
  29526. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29527. */
  29528. /**
  29529. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29530. */
  29531. idleRotationSpinupTime: number;
  29532. /**
  29533. * Gets a value indicating if the camera is currently rotating because of this behavior
  29534. */
  29535. readonly rotationInProgress: boolean;
  29536. private _onPrePointerObservableObserver;
  29537. private _onAfterCheckInputsObserver;
  29538. private _attachedCamera;
  29539. private _isPointerDown;
  29540. private _lastFrameTime;
  29541. private _lastInteractionTime;
  29542. private _cameraRotationSpeed;
  29543. init(): void;
  29544. attach(camera: ArcRotateCamera): void;
  29545. detach(): void;
  29546. /**
  29547. * Returns true if user is scrolling.
  29548. * @return true if user is scrolling.
  29549. */
  29550. private _userIsZooming();
  29551. private _lastFrameRadius;
  29552. private _shouldAnimationStopForInteraction();
  29553. /**
  29554. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29555. */
  29556. private _applyUserInteraction();
  29557. private _userIsMoving();
  29558. }
  29559. }
  29560. declare module BABYLON {
  29561. /**
  29562. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  29563. */
  29564. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  29565. readonly name: string;
  29566. /**
  29567. * The easing function used by animations
  29568. */
  29569. static EasingFunction: BackEase;
  29570. /**
  29571. * The easing mode used by animations
  29572. */
  29573. static EasingMode: number;
  29574. /**
  29575. * The duration of the animation, in milliseconds
  29576. */
  29577. transitionDuration: number;
  29578. /**
  29579. * Length of the distance animated by the transition when lower radius is reached
  29580. */
  29581. lowerRadiusTransitionRange: number;
  29582. /**
  29583. * Length of the distance animated by the transition when upper radius is reached
  29584. */
  29585. upperRadiusTransitionRange: number;
  29586. private _autoTransitionRange;
  29587. /**
  29588. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29589. */
  29590. /**
  29591. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29592. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  29593. */
  29594. autoTransitionRange: boolean;
  29595. private _attachedCamera;
  29596. private _onAfterCheckInputsObserver;
  29597. private _onMeshTargetChangedObserver;
  29598. init(): void;
  29599. attach(camera: ArcRotateCamera): void;
  29600. detach(): void;
  29601. private _radiusIsAnimating;
  29602. private _radiusBounceTransition;
  29603. private _animatables;
  29604. private _cachedWheelPrecision;
  29605. /**
  29606. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  29607. * @param radiusLimit The limit to check against.
  29608. * @return Bool to indicate if at limit.
  29609. */
  29610. private _isRadiusAtLimit(radiusLimit);
  29611. /**
  29612. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29613. * @param radiusDelta The delta by which to animate to. Can be negative.
  29614. */
  29615. private _applyBoundRadiusAnimation(radiusDelta);
  29616. /**
  29617. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29618. */
  29619. protected _clearAnimationLocks(): void;
  29620. /**
  29621. * Stops and removes all animations that have been applied to the camera
  29622. */
  29623. stopAllAnimations(): void;
  29624. }
  29625. }
  29626. declare module BABYLON {
  29627. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29628. readonly name: string;
  29629. private _mode;
  29630. private _radiusScale;
  29631. private _positionScale;
  29632. private _defaultElevation;
  29633. private _elevationReturnTime;
  29634. private _elevationReturnWaitTime;
  29635. private _zoomStopsAnimation;
  29636. private _framingTime;
  29637. /**
  29638. * The easing function used by animations
  29639. */
  29640. static EasingFunction: ExponentialEase;
  29641. /**
  29642. * The easing mode used by animations
  29643. */
  29644. static EasingMode: number;
  29645. /**
  29646. * Gets current mode used by the behavior.
  29647. */
  29648. /**
  29649. * Sets the current mode used by the behavior
  29650. */
  29651. mode: number;
  29652. /**
  29653. * Gets the scale applied to the radius
  29654. */
  29655. /**
  29656. * Sets the scale applied to the radius (1 by default)
  29657. */
  29658. radiusScale: number;
  29659. /**
  29660. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29661. */
  29662. /**
  29663. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29664. */
  29665. positionScale: number;
  29666. /**
  29667. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29668. * behaviour is triggered, in radians.
  29669. */
  29670. /**
  29671. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29672. * behaviour is triggered, in radians.
  29673. */
  29674. defaultElevation: number;
  29675. /**
  29676. * Gets the time (in milliseconds) taken to return to the default beta position.
  29677. * Negative value indicates camera should not return to default.
  29678. */
  29679. /**
  29680. * Sets the time (in milliseconds) taken to return to the default beta position.
  29681. * Negative value indicates camera should not return to default.
  29682. */
  29683. elevationReturnTime: number;
  29684. /**
  29685. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29686. */
  29687. /**
  29688. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29689. */
  29690. elevationReturnWaitTime: number;
  29691. /**
  29692. * Gets the flag that indicates if user zooming should stop animation.
  29693. */
  29694. /**
  29695. * Sets the flag that indicates if user zooming should stop animation.
  29696. */
  29697. zoomStopsAnimation: boolean;
  29698. /**
  29699. * Gets the transition time when framing the mesh, in milliseconds
  29700. */
  29701. /**
  29702. * Sets the transition time when framing the mesh, in milliseconds
  29703. */
  29704. framingTime: number;
  29705. private _onPrePointerObservableObserver;
  29706. private _onAfterCheckInputsObserver;
  29707. private _onMeshTargetChangedObserver;
  29708. private _attachedCamera;
  29709. private _isPointerDown;
  29710. private _lastInteractionTime;
  29711. init(): void;
  29712. attach(camera: ArcRotateCamera): void;
  29713. detach(): void;
  29714. private _animatables;
  29715. private _betaIsAnimating;
  29716. private _betaTransition;
  29717. private _radiusTransition;
  29718. private _vectorTransition;
  29719. /**
  29720. * Targets the given mesh and updates zoom level accordingly.
  29721. * @param mesh The mesh to target.
  29722. * @param radius Optional. If a cached radius position already exists, overrides default.
  29723. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29724. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29725. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29726. */
  29727. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29728. /**
  29729. * Targets the given mesh with its children and updates zoom level accordingly.
  29730. * @param mesh The mesh to target.
  29731. * @param radius Optional. If a cached radius position already exists, overrides default.
  29732. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29733. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29734. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29735. */
  29736. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29737. /**
  29738. * Targets the given meshes with their children and updates zoom level accordingly.
  29739. * @param meshes The mesh to target.
  29740. * @param radius Optional. If a cached radius position already exists, overrides default.
  29741. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29742. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29743. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29744. */
  29745. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29746. /**
  29747. * Targets the given mesh and updates zoom level accordingly.
  29748. * @param mesh The mesh to target.
  29749. * @param radius Optional. If a cached radius position already exists, overrides default.
  29750. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29751. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29752. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29753. */
  29754. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29755. /**
  29756. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29757. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29758. * frustum width.
  29759. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29760. * to fully enclose the mesh in the viewing frustum.
  29761. */
  29762. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29763. /**
  29764. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29765. * is automatically returned to its default position (expected to be above ground plane).
  29766. */
  29767. private _maintainCameraAboveGround();
  29768. /**
  29769. * Returns the frustum slope based on the canvas ratio and camera FOV
  29770. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29771. */
  29772. private _getFrustumSlope();
  29773. /**
  29774. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29775. */
  29776. private _clearAnimationLocks();
  29777. /**
  29778. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29779. */
  29780. private _applyUserInteraction();
  29781. /**
  29782. * Stops and removes all animations that have been applied to the camera
  29783. */
  29784. stopAllAnimations(): void;
  29785. /**
  29786. * Gets a value indicating if the user is moving the camera
  29787. */
  29788. readonly isUserIsMoving: boolean;
  29789. /**
  29790. * The camera can move all the way towards the mesh.
  29791. */
  29792. static IgnoreBoundsSizeMode: number;
  29793. /**
  29794. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29795. */
  29796. static FitFrustumSidesMode: number;
  29797. }
  29798. }
  29799. declare module BABYLON {
  29800. /**
  29801. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  29802. */
  29803. class PointerDragBehavior implements Behavior<Mesh> {
  29804. private options;
  29805. private _attachedNode;
  29806. private _dragPlane;
  29807. private _scene;
  29808. private _pointerObserver;
  29809. private static _planeScene;
  29810. private _draggingID;
  29811. /**
  29812. * Fires each time the attached mesh is dragged with the pointer
  29813. */
  29814. onDragObservable: Observable<{
  29815. delta: Vector3;
  29816. dragPlanePoint: Vector3;
  29817. }>;
  29818. /**
  29819. * Fires each time a drag begins (eg. mouse down on mesh)
  29820. */
  29821. onDragStartObservable: Observable<{
  29822. dragPlanePoint: Vector3;
  29823. }>;
  29824. /**
  29825. * Fires each time a drag ends (eg. mouse release after drag)
  29826. */
  29827. onDragEndObservable: Observable<{
  29828. dragPlanePoint: Vector3;
  29829. }>;
  29830. /**
  29831. * If the attached mesh should be moved when dragged
  29832. */
  29833. moveAttached: boolean;
  29834. /**
  29835. * Mesh with the position where the drag plane should be placed
  29836. */
  29837. _dragPlaneParent: Nullable<Mesh>;
  29838. /**
  29839. * If the drag behavior will react to drag events
  29840. */
  29841. enabled: boolean;
  29842. /**
  29843. * Creates a pointer drag behavior that can be attached to a mesh
  29844. * @param options The drag axis or normal of the plane that will be dragged across. pointerObservableScene can be used to listen to drag events from another scene(eg. if the attached mesh is in an overlay scene).
  29845. */
  29846. constructor(options: {
  29847. dragAxis?: Vector3;
  29848. dragPlaneNormal?: Vector3;
  29849. pointerObservableScene?: Scene;
  29850. });
  29851. /**
  29852. * The name of the behavior
  29853. */
  29854. readonly name: string;
  29855. /**
  29856. * Initializes the behavior
  29857. */
  29858. init(): void;
  29859. /**
  29860. * Attaches the drag behavior the passed in mesh
  29861. * @param ownerNode The mesh that will be dragged around once attached
  29862. */
  29863. attach(ownerNode: Mesh): void;
  29864. private _pickWithRayOnDragPlane(ray);
  29865. private _updateDragPlanePosition(ray);
  29866. /**
  29867. * Detaches the behavior from the mesh
  29868. */
  29869. detach(): void;
  29870. }
  29871. }
  29872. declare module BABYLON {
  29873. interface IOctreeContainer<T> {
  29874. blocks: Array<OctreeBlock<T>>;
  29875. }
  29876. class Octree<T> {
  29877. maxDepth: number;
  29878. blocks: Array<OctreeBlock<T>>;
  29879. dynamicContent: T[];
  29880. private _maxBlockCapacity;
  29881. private _selectionContent;
  29882. private _creationFunc;
  29883. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  29884. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  29885. addMesh(entry: T): void;
  29886. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  29887. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  29888. intersectsRay(ray: Ray): SmartArray<T>;
  29889. 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;
  29890. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  29891. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  29892. }
  29893. }
  29894. declare module BABYLON {
  29895. class OctreeBlock<T> {
  29896. entries: T[];
  29897. blocks: Array<OctreeBlock<T>>;
  29898. private _depth;
  29899. private _maxDepth;
  29900. private _capacity;
  29901. private _minPoint;
  29902. private _maxPoint;
  29903. private _boundingVectors;
  29904. private _creationFunc;
  29905. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  29906. readonly capacity: number;
  29907. readonly minPoint: Vector3;
  29908. readonly maxPoint: Vector3;
  29909. addEntry(entry: T): void;
  29910. addEntries(entries: T[]): void;
  29911. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29912. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29913. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  29914. createInnerBlocks(): void;
  29915. }
  29916. }
  29917. declare module BABYLON {
  29918. class VRCameraMetrics {
  29919. hResolution: number;
  29920. vResolution: number;
  29921. hScreenSize: number;
  29922. vScreenSize: number;
  29923. vScreenCenter: number;
  29924. eyeToScreenDistance: number;
  29925. lensSeparationDistance: number;
  29926. interpupillaryDistance: number;
  29927. distortionK: number[];
  29928. chromaAbCorrection: number[];
  29929. postProcessScaleFactor: number;
  29930. lensCenterOffset: number;
  29931. compensateDistortion: boolean;
  29932. readonly aspectRatio: number;
  29933. readonly aspectRatioFov: number;
  29934. readonly leftHMatrix: Matrix;
  29935. readonly rightHMatrix: Matrix;
  29936. readonly leftPreViewMatrix: Matrix;
  29937. readonly rightPreViewMatrix: Matrix;
  29938. static GetDefault(): VRCameraMetrics;
  29939. }
  29940. }
  29941. declare module BABYLON {
  29942. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29943. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29944. getClassName(): string;
  29945. }
  29946. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29947. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29948. getClassName(): string;
  29949. }
  29950. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29951. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29952. getClassName(): string;
  29953. }
  29954. }
  29955. declare module BABYLON {
  29956. /**
  29957. * Options to modify the vr teleportation behavior.
  29958. */
  29959. interface VRTeleportationOptions {
  29960. /**
  29961. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29962. */
  29963. floorMeshName?: string;
  29964. /**
  29965. * A list of meshes to be used as the teleportation floor. (default: empty)
  29966. */
  29967. floorMeshes?: Mesh[];
  29968. }
  29969. /**
  29970. * Options to modify the vr experience helper's behavior.
  29971. */
  29972. interface VRExperienceHelperOptions extends WebVROptions {
  29973. /**
  29974. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  29975. */
  29976. createDeviceOrientationCamera?: boolean;
  29977. /**
  29978. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  29979. */
  29980. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29981. /**
  29982. * Uses the main button on the controller to toggle the laser casted. (default: true)
  29983. */
  29984. laserToggle?: boolean;
  29985. /**
  29986. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  29987. */
  29988. floorMeshes?: Mesh[];
  29989. }
  29990. /**
  29991. * Helps to quickly add VR support to an existing scene.
  29992. * See http://doc.babylonjs.com/how_to/webvr_helper
  29993. */
  29994. class VRExperienceHelper {
  29995. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29996. private _scene;
  29997. private _position;
  29998. private _btnVR;
  29999. private _btnVRDisplayed;
  30000. private _webVRsupported;
  30001. private _webVRready;
  30002. private _webVRrequesting;
  30003. private _webVRpresenting;
  30004. private _fullscreenVRpresenting;
  30005. private _canvas;
  30006. private _webVRCamera;
  30007. private _vrDeviceOrientationCamera;
  30008. private _deviceOrientationCamera;
  30009. private _existingCamera;
  30010. private _onKeyDown;
  30011. private _onVrDisplayPresentChange;
  30012. private _onVRDisplayChanged;
  30013. private _onVRRequestPresentStart;
  30014. private _onVRRequestPresentComplete;
  30015. /**
  30016. * Observable raised when entering VR.
  30017. */
  30018. onEnteringVRObservable: Observable<VRExperienceHelper>;
  30019. /**
  30020. * Observable raised when exiting VR.
  30021. */
  30022. onExitingVRObservable: Observable<VRExperienceHelper>;
  30023. /**
  30024. * Observable raised when controller mesh is loaded.
  30025. */
  30026. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30027. /** Return this.onEnteringVRObservable
  30028. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  30029. */
  30030. readonly onEnteringVR: Observable<VRExperienceHelper>;
  30031. /** Return this.onExitingVRObservable
  30032. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  30033. */
  30034. readonly onExitingVR: Observable<VRExperienceHelper>;
  30035. /** Return this.onControllerMeshLoadedObservable
  30036. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  30037. */
  30038. readonly onControllerMeshLoaded: Observable<WebVRController>;
  30039. private _rayLength;
  30040. private _useCustomVRButton;
  30041. private _teleportationRequested;
  30042. private _teleportActive;
  30043. private _floorMeshName;
  30044. private _floorMeshesCollection;
  30045. private _rotationAllowed;
  30046. private _teleportBackwardsVector;
  30047. private _teleportationTarget;
  30048. private _isDefaultTeleportationTarget;
  30049. private _postProcessMove;
  30050. private _teleportationFillColor;
  30051. private _teleportationBorderColor;
  30052. private _rotationAngle;
  30053. private _haloCenter;
  30054. private _cameraGazer;
  30055. private _padSensibilityUp;
  30056. private _padSensibilityDown;
  30057. private leftController;
  30058. private rightController;
  30059. /**
  30060. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  30061. */
  30062. onNewMeshSelected: Observable<AbstractMesh>;
  30063. /**
  30064. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  30065. */
  30066. onNewMeshPicked: Observable<PickingInfo>;
  30067. private _circleEase;
  30068. /**
  30069. * Observable raised before camera teleportation
  30070. */
  30071. onBeforeCameraTeleport: Observable<Vector3>;
  30072. /**
  30073. * Observable raised after camera teleportation
  30074. */
  30075. onAfterCameraTeleport: Observable<Vector3>;
  30076. /**
  30077. * Observable raised when current selected mesh gets unselected
  30078. */
  30079. onSelectedMeshUnselected: Observable<AbstractMesh>;
  30080. private _raySelectionPredicate;
  30081. /**
  30082. * To be optionaly changed by user to define custom ray selection
  30083. */
  30084. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  30085. /**
  30086. * To be optionaly changed by user to define custom selection logic (after ray selection)
  30087. */
  30088. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  30089. /**
  30090. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  30091. */
  30092. teleportationEnabled: boolean;
  30093. private _defaultHeight;
  30094. private _teleportationInitialized;
  30095. private _interactionsEnabled;
  30096. private _interactionsRequested;
  30097. private _displayGaze;
  30098. private _displayLaserPointer;
  30099. /**
  30100. * The mesh used to display where the user is going to teleport.
  30101. */
  30102. /**
  30103. * Sets the mesh to be used to display where the user is going to teleport.
  30104. */
  30105. teleportationTarget: Mesh;
  30106. /**
  30107. * The mesh used to display where the user is selecting,
  30108. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  30109. * See http://doc.babylonjs.com/resources/baking_transformations
  30110. */
  30111. gazeTrackerMesh: Mesh;
  30112. /**
  30113. * If the ray of the gaze should be displayed.
  30114. */
  30115. /**
  30116. * Sets if the ray of the gaze should be displayed.
  30117. */
  30118. displayGaze: boolean;
  30119. /**
  30120. * If the ray of the LaserPointer should be displayed.
  30121. */
  30122. /**
  30123. * Sets if the ray of the LaserPointer should be displayed.
  30124. */
  30125. displayLaserPointer: boolean;
  30126. /**
  30127. * The deviceOrientationCamera used as the camera when not in VR.
  30128. */
  30129. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  30130. /**
  30131. * Based on the current WebVR support, returns the current VR camera used.
  30132. */
  30133. readonly currentVRCamera: Nullable<Camera>;
  30134. /**
  30135. * The webVRCamera which is used when in VR.
  30136. */
  30137. readonly webVRCamera: WebVRFreeCamera;
  30138. /**
  30139. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  30140. */
  30141. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  30142. private readonly _teleportationRequestInitiated;
  30143. /**
  30144. * Instantiates a VRExperienceHelper.
  30145. * Helps to quickly add VR support to an existing scene.
  30146. * @param scene The scene the VRExperienceHelper belongs to.
  30147. * @param webVROptions Options to modify the vr experience helper's behavior.
  30148. */
  30149. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  30150. private _onDefaultMeshLoaded(webVRController);
  30151. private _onResize;
  30152. private _onFullscreenChange;
  30153. /**
  30154. * Gets a value indicating if we are currently in VR mode.
  30155. */
  30156. readonly isInVRMode: boolean;
  30157. private onVrDisplayPresentChange();
  30158. private onVRDisplayChanged(eventArgs);
  30159. private moveButtonToBottomRight();
  30160. private displayVRButton();
  30161. private updateButtonVisibility();
  30162. /**
  30163. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  30164. * Otherwise, will use the fullscreen API.
  30165. */
  30166. enterVR(): void;
  30167. /**
  30168. * Attempt to exit VR, or fullscreen.
  30169. */
  30170. exitVR(): void;
  30171. /**
  30172. * The position of the vr experience helper.
  30173. */
  30174. /**
  30175. * Sets the position of the vr experience helper.
  30176. */
  30177. position: Vector3;
  30178. /**
  30179. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  30180. */
  30181. enableInteractions(): void;
  30182. private beforeRender;
  30183. private _isTeleportationFloor(mesh);
  30184. /**
  30185. * Adds a floor mesh to be used for teleportation.
  30186. * @param floorMesh the mesh to be used for teleportation.
  30187. */
  30188. addFloorMesh(floorMesh: Mesh): void;
  30189. /**
  30190. * Removes a floor mesh from being used for teleportation.
  30191. * @param floorMesh the mesh to be removed.
  30192. */
  30193. removeFloorMesh(floorMesh: Mesh): void;
  30194. /**
  30195. * Enables interactions and teleportation using the VR controllers and gaze.
  30196. * @param vrTeleportationOptions options to modify teleportation behavior.
  30197. */
  30198. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  30199. private _onNewGamepadConnected;
  30200. private _tryEnableInteractionOnController;
  30201. private _onNewGamepadDisconnected;
  30202. private _enableInteractionOnController(controller);
  30203. private _checkTeleportWithRay(stateObject, gazer);
  30204. private _checkRotate(stateObject, gazer);
  30205. private _checkTeleportBackwards(stateObject, gazer);
  30206. private _enableTeleportationOnController(controller);
  30207. private _createTeleportationCircles();
  30208. private _displayTeleportationTarget();
  30209. private _hideTeleportationTarget();
  30210. private _rotateCamera(right);
  30211. private _moveTeleportationSelectorTo(hit, gazer, ray);
  30212. private _workingVector;
  30213. private _workingQuaternion;
  30214. private _workingMatrix;
  30215. private _teleportCamera(location);
  30216. private _convertNormalToDirectionOfRay(normal, ray);
  30217. private _castRayAndSelectObject(gazer);
  30218. private _notifySelectedMeshUnselected(mesh);
  30219. /**
  30220. * Sets the color of the laser ray from the vr controllers.
  30221. * @param color new color for the ray.
  30222. */
  30223. changeLaserColor(color: Color3): void;
  30224. /**
  30225. * Sets the color of the ray from the vr headsets gaze.
  30226. * @param color new color for the ray.
  30227. */
  30228. changeGazeColor(color: Color3): void;
  30229. /**
  30230. * Exits VR and disposes of the vr experience helper
  30231. */
  30232. dispose(): void;
  30233. /**
  30234. * Gets the name of the VRExperienceHelper class
  30235. * @returns "VRExperienceHelper"
  30236. */
  30237. getClassName(): string;
  30238. }
  30239. }
  30240. declare module BABYLON {
  30241. /**
  30242. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  30243. * IMPORTANT!! The data is right-hand data.
  30244. * @export
  30245. * @interface DevicePose
  30246. */
  30247. interface DevicePose {
  30248. /**
  30249. * The position of the device, values in array are [x,y,z].
  30250. */
  30251. readonly position: Nullable<Float32Array>;
  30252. /**
  30253. * The linearVelocity of the device, values in array are [x,y,z].
  30254. */
  30255. readonly linearVelocity: Nullable<Float32Array>;
  30256. /**
  30257. * The linearAcceleration of the device, values in array are [x,y,z].
  30258. */
  30259. readonly linearAcceleration: Nullable<Float32Array>;
  30260. /**
  30261. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  30262. */
  30263. readonly orientation: Nullable<Float32Array>;
  30264. /**
  30265. * The angularVelocity of the device, values in array are [x,y,z].
  30266. */
  30267. readonly angularVelocity: Nullable<Float32Array>;
  30268. /**
  30269. * The angularAcceleration of the device, values in array are [x,y,z].
  30270. */
  30271. readonly angularAcceleration: Nullable<Float32Array>;
  30272. }
  30273. /**
  30274. * Interface representing a pose controlled object in Babylon.
  30275. * A pose controlled object has both regular pose values as well as pose values
  30276. * from an external device such as a VR head mounted display
  30277. */
  30278. interface PoseControlled {
  30279. /**
  30280. * The position of the object in babylon space.
  30281. */
  30282. position: Vector3;
  30283. /**
  30284. * The rotation quaternion of the object in babylon space.
  30285. */
  30286. rotationQuaternion: Quaternion;
  30287. /**
  30288. * The position of the device in babylon space.
  30289. */
  30290. devicePosition?: Vector3;
  30291. /**
  30292. * The rotation quaternion of the device in babylon space.
  30293. */
  30294. deviceRotationQuaternion: Quaternion;
  30295. /**
  30296. * The raw pose coming from the device.
  30297. */
  30298. rawPose: Nullable<DevicePose>;
  30299. /**
  30300. * The scale of the device to be used when translating from device space to babylon space.
  30301. */
  30302. deviceScaleFactor: number;
  30303. /**
  30304. * Updates the poseControlled values based on the input device pose.
  30305. * @param poseData the pose data to update the object with
  30306. */
  30307. updateFromDevice(poseData: DevicePose): void;
  30308. }
  30309. /**
  30310. * Set of options to customize the webVRCamera
  30311. */
  30312. interface WebVROptions {
  30313. /**
  30314. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  30315. */
  30316. trackPosition?: boolean;
  30317. /**
  30318. * Sets the scale of the vrDevice in babylon space. (default: 1)
  30319. */
  30320. positionScale?: number;
  30321. /**
  30322. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  30323. */
  30324. displayName?: string;
  30325. /**
  30326. * Should the native controller meshes be initialized. (default: true)
  30327. */
  30328. controllerMeshes?: boolean;
  30329. /**
  30330. * Creating a default HemiLight only on controllers. (default: true)
  30331. */
  30332. defaultLightingOnControllers?: boolean;
  30333. /**
  30334. * If you don't want to use the default VR button of the helper. (default: false)
  30335. */
  30336. useCustomVRButton?: boolean;
  30337. /**
  30338. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  30339. */
  30340. customVRButton?: HTMLButtonElement;
  30341. /**
  30342. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  30343. */
  30344. rayLength?: number;
  30345. /**
  30346. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  30347. */
  30348. defaultHeight?: number;
  30349. }
  30350. /**
  30351. * This represents a WebVR camera.
  30352. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  30353. * @example http://doc.babylonjs.com/how_to/webvr_camera
  30354. */
  30355. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  30356. private webVROptions;
  30357. /**
  30358. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  30359. */
  30360. _vrDevice: any;
  30361. /**
  30362. * The rawPose of the vrDevice.
  30363. */
  30364. rawPose: Nullable<DevicePose>;
  30365. private _onVREnabled;
  30366. private _specsVersion;
  30367. private _attached;
  30368. private _frameData;
  30369. protected _descendants: Array<Node>;
  30370. private _deviceRoomPosition;
  30371. private _deviceRoomRotationQuaternion;
  30372. private _standingMatrix;
  30373. /**
  30374. * Represents device position in babylon space.
  30375. */
  30376. devicePosition: Vector3;
  30377. /**
  30378. * Represents device rotation in babylon space.
  30379. */
  30380. deviceRotationQuaternion: Quaternion;
  30381. /**
  30382. * The scale of the device to be used when translating from device space to babylon space.
  30383. */
  30384. deviceScaleFactor: number;
  30385. private _deviceToWorld;
  30386. private _worldToDevice;
  30387. /**
  30388. * References to the webVR controllers for the vrDevice.
  30389. */
  30390. controllers: Array<WebVRController>;
  30391. /**
  30392. * Emits an event when a controller is attached.
  30393. */
  30394. onControllersAttachedObservable: Observable<WebVRController[]>;
  30395. /**
  30396. * Emits an event when a controller's mesh has been loaded;
  30397. */
  30398. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30399. /**
  30400. * If the rig cameras be used as parent instead of this camera.
  30401. */
  30402. rigParenting: boolean;
  30403. private _lightOnControllers;
  30404. private _defaultHeight?;
  30405. /**
  30406. * Instantiates a WebVRFreeCamera.
  30407. * @param name The name of the WebVRFreeCamera
  30408. * @param position The starting anchor position for the camera
  30409. * @param scene The scene the camera belongs to
  30410. * @param webVROptions a set of customizable options for the webVRCamera
  30411. */
  30412. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  30413. /**
  30414. * Gets the device distance from the ground in meters.
  30415. * @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.
  30416. */
  30417. deviceDistanceToRoomGround(): number;
  30418. /**
  30419. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30420. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  30421. */
  30422. useStandingMatrix(callback?: (bool: boolean) => void): void;
  30423. /**
  30424. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30425. * @returns A promise with a boolean set to if the standing matrix is supported.
  30426. */
  30427. useStandingMatrixAsync(): Promise<boolean>;
  30428. /**
  30429. * Disposes the camera
  30430. */
  30431. dispose(): void;
  30432. /**
  30433. * Gets a vrController by name.
  30434. * @param name The name of the controller to retreive
  30435. * @returns the controller matching the name specified or null if not found
  30436. */
  30437. getControllerByName(name: string): Nullable<WebVRController>;
  30438. private _leftController;
  30439. /**
  30440. * The controller corrisponding to the users left hand.
  30441. */
  30442. readonly leftController: Nullable<WebVRController>;
  30443. private _rightController;
  30444. /**
  30445. * The controller corrisponding to the users right hand.
  30446. */
  30447. readonly rightController: Nullable<WebVRController>;
  30448. /**
  30449. * Casts a ray forward from the vrCamera's gaze.
  30450. * @param length Length of the ray (default: 100)
  30451. * @returns the ray corrisponding to the gaze
  30452. */
  30453. getForwardRay(length?: number): Ray;
  30454. /**
  30455. * Updates the camera based on device's frame data
  30456. */
  30457. _checkInputs(): void;
  30458. /**
  30459. * Updates the poseControlled values based on the input device pose.
  30460. * @param poseData Pose coming from the device
  30461. */
  30462. updateFromDevice(poseData: DevicePose): void;
  30463. /**
  30464. * WebVR's attach control will start broadcasting frames to the device.
  30465. * Note that in certain browsers (chrome for example) this function must be called
  30466. * within a user-interaction callback. Example:
  30467. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  30468. *
  30469. * @param element html element to attach the vrDevice to
  30470. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  30471. */
  30472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30473. /**
  30474. * Detaches the camera from the html element and disables VR
  30475. *
  30476. * @param element html element to detach from
  30477. */
  30478. detachControl(element: HTMLElement): void;
  30479. /**
  30480. * @returns the name of this class
  30481. */
  30482. getClassName(): string;
  30483. /**
  30484. * Calls resetPose on the vrDisplay
  30485. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  30486. */
  30487. resetToCurrentRotation(): void;
  30488. /**
  30489. * Updates the rig cameras (left and right eye)
  30490. */
  30491. _updateRigCameras(): void;
  30492. private _workingVector;
  30493. private _oneVector;
  30494. private _workingMatrix;
  30495. private updateCacheCalled;
  30496. /**
  30497. * Updates the cached values of the camera
  30498. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  30499. */
  30500. _updateCache(ignoreParentClass?: boolean): void;
  30501. /**
  30502. * Updates the current device position and rotation in the babylon world
  30503. */
  30504. update(): void;
  30505. /**
  30506. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  30507. * @returns an identity matrix
  30508. */
  30509. _getViewMatrix(): Matrix;
  30510. /**
  30511. * This function is called by the two RIG cameras.
  30512. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  30513. */
  30514. protected _getWebVRViewMatrix(): Matrix;
  30515. protected _getWebVRProjectionMatrix(): Matrix;
  30516. private _onGamepadConnectedObserver;
  30517. private _onGamepadDisconnectedObserver;
  30518. /**
  30519. * Initializes the controllers and their meshes
  30520. */
  30521. initControllers(): void;
  30522. }
  30523. }
  30524. declare module BABYLON {
  30525. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  30526. camera: ArcRotateCamera;
  30527. gamepad: Nullable<Gamepad>;
  30528. private _onGamepadConnectedObserver;
  30529. private _onGamepadDisconnectedObserver;
  30530. gamepadRotationSensibility: number;
  30531. gamepadMoveSensibility: number;
  30532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30533. detachControl(element: Nullable<HTMLElement>): void;
  30534. checkInputs(): void;
  30535. getClassName(): string;
  30536. getSimpleName(): string;
  30537. }
  30538. }
  30539. declare module BABYLON {
  30540. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  30541. camera: ArcRotateCamera;
  30542. private _keys;
  30543. keysUp: number[];
  30544. keysDown: number[];
  30545. keysLeft: number[];
  30546. keysRight: number[];
  30547. keysReset: number[];
  30548. panningSensibility: number;
  30549. zoomingSensibility: number;
  30550. useAltToZoom: boolean;
  30551. private _ctrlPressed;
  30552. private _altPressed;
  30553. private _onCanvasBlurObserver;
  30554. private _onKeyboardObserver;
  30555. private _engine;
  30556. private _scene;
  30557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30558. detachControl(element: Nullable<HTMLElement>): void;
  30559. checkInputs(): void;
  30560. getClassName(): string;
  30561. getSimpleName(): string;
  30562. }
  30563. }
  30564. declare module BABYLON {
  30565. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  30566. camera: ArcRotateCamera;
  30567. private _wheel;
  30568. private _observer;
  30569. wheelPrecision: number;
  30570. /**
  30571. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  30572. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  30573. */
  30574. wheelDeltaPercentage: number;
  30575. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30576. detachControl(element: Nullable<HTMLElement>): void;
  30577. getClassName(): string;
  30578. getSimpleName(): string;
  30579. }
  30580. }
  30581. declare module BABYLON {
  30582. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  30583. camera: ArcRotateCamera;
  30584. buttons: number[];
  30585. angularSensibilityX: number;
  30586. angularSensibilityY: number;
  30587. pinchPrecision: number;
  30588. /**
  30589. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  30590. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  30591. */
  30592. pinchDeltaPercentage: number;
  30593. panningSensibility: number;
  30594. multiTouchPanning: boolean;
  30595. multiTouchPanAndZoom: boolean;
  30596. private _isPanClick;
  30597. pinchInwards: boolean;
  30598. private _pointerInput;
  30599. private _observer;
  30600. private _onMouseMove;
  30601. private _onGestureStart;
  30602. private _onGesture;
  30603. private _MSGestureHandler;
  30604. private _onLostFocus;
  30605. private _onContextMenu;
  30606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30607. detachControl(element: Nullable<HTMLElement>): void;
  30608. getClassName(): string;
  30609. getSimpleName(): string;
  30610. }
  30611. }
  30612. declare module BABYLON {
  30613. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  30614. camera: ArcRotateCamera;
  30615. alphaCorrection: number;
  30616. betaCorrection: number;
  30617. gammaCorrection: number;
  30618. private _alpha;
  30619. private _gamma;
  30620. private _dirty;
  30621. private _deviceOrientationHandler;
  30622. constructor();
  30623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30624. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  30625. checkInputs(): void;
  30626. detachControl(element: Nullable<HTMLElement>): void;
  30627. getClassName(): string;
  30628. getSimpleName(): string;
  30629. }
  30630. }
  30631. declare module BABYLON {
  30632. /**
  30633. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  30634. * Screen rotation is taken into account.
  30635. */
  30636. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  30637. private _camera;
  30638. private _screenOrientationAngle;
  30639. private _constantTranform;
  30640. private _screenQuaternion;
  30641. private _alpha;
  30642. private _beta;
  30643. private _gamma;
  30644. constructor();
  30645. camera: FreeCamera;
  30646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30647. private _orientationChanged;
  30648. private _deviceOrientation;
  30649. detachControl(element: Nullable<HTMLElement>): void;
  30650. checkInputs(): void;
  30651. getClassName(): string;
  30652. getSimpleName(): string;
  30653. }
  30654. }
  30655. declare module BABYLON {
  30656. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  30657. camera: FreeCamera;
  30658. gamepad: Nullable<Gamepad>;
  30659. private _onGamepadConnectedObserver;
  30660. private _onGamepadDisconnectedObserver;
  30661. gamepadAngularSensibility: number;
  30662. gamepadMoveSensibility: number;
  30663. private _cameraTransform;
  30664. private _deltaTransform;
  30665. private _vector3;
  30666. private _vector2;
  30667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30668. detachControl(element: Nullable<HTMLElement>): void;
  30669. checkInputs(): void;
  30670. getClassName(): string;
  30671. getSimpleName(): string;
  30672. }
  30673. }
  30674. declare module BABYLON {
  30675. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  30676. camera: FreeCamera;
  30677. private _keys;
  30678. private _onCanvasBlurObserver;
  30679. private _onKeyboardObserver;
  30680. private _engine;
  30681. private _scene;
  30682. keysUp: number[];
  30683. keysDown: number[];
  30684. keysLeft: number[];
  30685. keysRight: number[];
  30686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30687. detachControl(element: Nullable<HTMLElement>): void;
  30688. checkInputs(): void;
  30689. getClassName(): string;
  30690. _onLostFocus(e: FocusEvent): void;
  30691. getSimpleName(): string;
  30692. }
  30693. }
  30694. declare module BABYLON {
  30695. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  30696. touchEnabled: boolean;
  30697. camera: FreeCamera;
  30698. buttons: number[];
  30699. angularSensibility: number;
  30700. private _pointerInput;
  30701. private _onMouseMove;
  30702. private _observer;
  30703. private previousPosition;
  30704. constructor(touchEnabled?: boolean);
  30705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30706. detachControl(element: Nullable<HTMLElement>): void;
  30707. getClassName(): string;
  30708. getSimpleName(): string;
  30709. }
  30710. }
  30711. declare module BABYLON {
  30712. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  30713. camera: FreeCamera;
  30714. private _offsetX;
  30715. private _offsetY;
  30716. private _pointerPressed;
  30717. private _pointerInput;
  30718. private _observer;
  30719. private _onLostFocus;
  30720. touchAngularSensibility: number;
  30721. touchMoveSensibility: number;
  30722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30723. detachControl(element: Nullable<HTMLElement>): void;
  30724. checkInputs(): void;
  30725. getClassName(): string;
  30726. getSimpleName(): string;
  30727. }
  30728. }
  30729. declare module BABYLON {
  30730. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  30731. camera: FreeCamera;
  30732. private _leftjoystick;
  30733. private _rightjoystick;
  30734. getLeftJoystick(): VirtualJoystick;
  30735. getRightJoystick(): VirtualJoystick;
  30736. checkInputs(): void;
  30737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30738. detachControl(element: Nullable<HTMLElement>): void;
  30739. getClassName(): string;
  30740. getSimpleName(): string;
  30741. }
  30742. }
  30743. declare module BABYLON {
  30744. /**
  30745. * Google Daydream controller
  30746. */
  30747. class DaydreamController extends WebVRController {
  30748. /**
  30749. * Base Url for the controller model.
  30750. */
  30751. static MODEL_BASE_URL: string;
  30752. /**
  30753. * File name for the controller model.
  30754. */
  30755. static MODEL_FILENAME: string;
  30756. /**
  30757. * Gamepad Id prefix used to identify Daydream Controller.
  30758. */
  30759. static readonly GAMEPAD_ID_PREFIX: string;
  30760. /**
  30761. * Creates a new DaydreamController from a gamepad
  30762. * @param vrGamepad the gamepad that the controller should be created from
  30763. */
  30764. constructor(vrGamepad: any);
  30765. /**
  30766. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30767. * @param scene scene in which to add meshes
  30768. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30769. */
  30770. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30771. /**
  30772. * Called once for each button that changed state since the last frame
  30773. * @param buttonIdx Which button index changed
  30774. * @param state New state of the button
  30775. * @param changes Which properties on the state changed since last frame
  30776. */
  30777. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30778. }
  30779. }
  30780. declare module BABYLON {
  30781. /**
  30782. * Gear VR Controller
  30783. */
  30784. class GearVRController extends WebVRController {
  30785. /**
  30786. * Base Url for the controller model.
  30787. */
  30788. static MODEL_BASE_URL: string;
  30789. /**
  30790. * File name for the controller model.
  30791. */
  30792. static MODEL_FILENAME: string;
  30793. /**
  30794. * Gamepad Id prefix used to identify this controller.
  30795. */
  30796. static readonly GAMEPAD_ID_PREFIX: string;
  30797. private readonly _buttonIndexToObservableNameMap;
  30798. /**
  30799. * Creates a new GearVRController from a gamepad
  30800. * @param vrGamepad the gamepad that the controller should be created from
  30801. */
  30802. constructor(vrGamepad: any);
  30803. /**
  30804. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30805. * @param scene scene in which to add meshes
  30806. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30807. */
  30808. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30809. /**
  30810. * Called once for each button that changed state since the last frame
  30811. * @param buttonIdx Which button index changed
  30812. * @param state New state of the button
  30813. * @param changes Which properties on the state changed since last frame
  30814. */
  30815. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30816. }
  30817. }
  30818. declare module BABYLON {
  30819. /**
  30820. * Generic Controller
  30821. */
  30822. class GenericController extends WebVRController {
  30823. /**
  30824. * Base Url for the controller model.
  30825. */
  30826. static readonly MODEL_BASE_URL: string;
  30827. /**
  30828. * File name for the controller model.
  30829. */
  30830. static readonly MODEL_FILENAME: string;
  30831. /**
  30832. * Creates a new GenericController from a gamepad
  30833. * @param vrGamepad the gamepad that the controller should be created from
  30834. */
  30835. constructor(vrGamepad: any);
  30836. /**
  30837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30838. * @param scene scene in which to add meshes
  30839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30840. */
  30841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30842. /**
  30843. * Called once for each button that changed state since the last frame
  30844. * @param buttonIdx Which button index changed
  30845. * @param state New state of the button
  30846. * @param changes Which properties on the state changed since last frame
  30847. */
  30848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30849. }
  30850. }
  30851. declare module BABYLON {
  30852. /**
  30853. * Oculus Touch Controller
  30854. */
  30855. class OculusTouchController extends WebVRController {
  30856. /**
  30857. * Base Url for the controller model.
  30858. */
  30859. static MODEL_BASE_URL: string;
  30860. /**
  30861. * File name for the left controller model.
  30862. */
  30863. static MODEL_LEFT_FILENAME: string;
  30864. /**
  30865. * File name for the right controller model.
  30866. */
  30867. static MODEL_RIGHT_FILENAME: string;
  30868. /**
  30869. * Fired when the secondary trigger on this controller is modified
  30870. */
  30871. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30872. /**
  30873. * Fired when the thumb rest on this controller is modified
  30874. */
  30875. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30876. /**
  30877. * Creates a new OculusTouchController from a gamepad
  30878. * @param vrGamepad the gamepad that the controller should be created from
  30879. */
  30880. constructor(vrGamepad: any);
  30881. /**
  30882. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30883. * @param scene scene in which to add meshes
  30884. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30885. */
  30886. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30887. /**
  30888. * Fired when the A button on this controller is modified
  30889. */
  30890. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30891. /**
  30892. * Fired when the B button on this controller is modified
  30893. */
  30894. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30895. /**
  30896. * Fired when the X button on this controller is modified
  30897. */
  30898. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30899. /**
  30900. * Fired when the Y button on this controller is modified
  30901. */
  30902. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30903. /**
  30904. * Called once for each button that changed state since the last frame
  30905. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30906. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30907. * 2) secondary trigger (same)
  30908. * 3) A (right) X (left), touch, pressed = value
  30909. * 4) B / Y
  30910. * 5) thumb rest
  30911. * @param buttonIdx Which button index changed
  30912. * @param state New state of the button
  30913. * @param changes Which properties on the state changed since last frame
  30914. */
  30915. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30916. }
  30917. }
  30918. declare module BABYLON {
  30919. /**
  30920. * Defines the types of pose enabled controllers that are supported
  30921. */
  30922. enum PoseEnabledControllerType {
  30923. /**
  30924. * HTC Vive
  30925. */
  30926. VIVE = 0,
  30927. /**
  30928. * Oculus Rift
  30929. */
  30930. OCULUS = 1,
  30931. /**
  30932. * Windows mixed reality
  30933. */
  30934. WINDOWS = 2,
  30935. /**
  30936. * Samsung gear VR
  30937. */
  30938. GEAR_VR = 3,
  30939. /**
  30940. * Google Daydream
  30941. */
  30942. DAYDREAM = 4,
  30943. /**
  30944. * Generic
  30945. */
  30946. GENERIC = 5,
  30947. }
  30948. /**
  30949. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30950. */
  30951. interface MutableGamepadButton {
  30952. /**
  30953. * Value of the button/trigger
  30954. */
  30955. value: number;
  30956. /**
  30957. * If the button/trigger is currently touched
  30958. */
  30959. touched: boolean;
  30960. /**
  30961. * If the button/trigger is currently pressed
  30962. */
  30963. pressed: boolean;
  30964. }
  30965. /**
  30966. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30967. * @hidden
  30968. */
  30969. interface ExtendedGamepadButton extends GamepadButton {
  30970. /**
  30971. * If the button/trigger is currently pressed
  30972. */
  30973. readonly pressed: boolean;
  30974. /**
  30975. * If the button/trigger is currently touched
  30976. */
  30977. readonly touched: boolean;
  30978. /**
  30979. * Value of the button/trigger
  30980. */
  30981. readonly value: number;
  30982. }
  30983. /**
  30984. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30985. */
  30986. class PoseEnabledControllerHelper {
  30987. /**
  30988. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30989. * @param vrGamepad the gamepad to initialized
  30990. * @returns a vr controller of the type the gamepad identified as
  30991. */
  30992. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30993. }
  30994. /**
  30995. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30996. */
  30997. class PoseEnabledController extends Gamepad implements PoseControlled {
  30998. private _deviceRoomPosition;
  30999. private _deviceRoomRotationQuaternion;
  31000. /**
  31001. * The device position in babylon space
  31002. */
  31003. devicePosition: Vector3;
  31004. /**
  31005. * The device rotation in babylon space
  31006. */
  31007. deviceRotationQuaternion: Quaternion;
  31008. /**
  31009. * The scale factor of the device in babylon space
  31010. */
  31011. deviceScaleFactor: number;
  31012. /**
  31013. * (Likely devicePosition should be used instead) The device position in its room space
  31014. */
  31015. position: Vector3;
  31016. /**
  31017. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  31018. */
  31019. rotationQuaternion: Quaternion;
  31020. /**
  31021. * The type of controller (Eg. Windows mixed reality)
  31022. */
  31023. controllerType: PoseEnabledControllerType;
  31024. protected _calculatedPosition: Vector3;
  31025. private _calculatedRotation;
  31026. /**
  31027. * The raw pose from the device
  31028. */
  31029. rawPose: DevicePose;
  31030. /**
  31031. * Internal, the mesh attached to the controller
  31032. */
  31033. _mesh: Nullable<AbstractMesh>;
  31034. private _poseControlledCamera;
  31035. private _leftHandSystemQuaternion;
  31036. /**
  31037. * Internal, matrix used to convert room space to babylon space
  31038. */
  31039. _deviceToWorld: Matrix;
  31040. /**
  31041. * Node to be used when casting a ray from the controller
  31042. */
  31043. _pointingPoseNode: Nullable<AbstractMesh>;
  31044. /**
  31045. * Name of the child mesh that can be used to cast a ray from the controller
  31046. */
  31047. static readonly POINTING_POSE: string;
  31048. /**
  31049. * Creates a new PoseEnabledController from a gamepad
  31050. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  31051. */
  31052. constructor(browserGamepad: any);
  31053. private _workingMatrix;
  31054. /**
  31055. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  31056. */
  31057. update(): void;
  31058. /**
  31059. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  31060. * @param poseData raw pose fromthe device
  31061. */
  31062. updateFromDevice(poseData: DevicePose): void;
  31063. /**
  31064. * @hidden
  31065. */
  31066. _meshAttachedObservable: Observable<AbstractMesh>;
  31067. /**
  31068. * Attaches a mesh to the controller
  31069. * @param mesh the mesh to be attached
  31070. */
  31071. attachToMesh(mesh: AbstractMesh): void;
  31072. /**
  31073. * Attaches the controllers mesh to a camera
  31074. * @param camera the camera the mesh should be attached to
  31075. */
  31076. attachToPoseControlledCamera(camera: TargetCamera): void;
  31077. /**
  31078. * Disposes of the controller
  31079. */
  31080. dispose(): void;
  31081. /**
  31082. * The mesh that is attached to the controller
  31083. */
  31084. readonly mesh: Nullable<AbstractMesh>;
  31085. /**
  31086. * Gets the ray of the controller in the direction the controller is pointing
  31087. * @param length the length the resulting ray should be
  31088. * @returns a ray in the direction the controller is pointing
  31089. */
  31090. getForwardRay(length?: number): Ray;
  31091. }
  31092. }
  31093. declare module BABYLON {
  31094. /**
  31095. * Vive Controller
  31096. */
  31097. class ViveController extends WebVRController {
  31098. /**
  31099. * Base Url for the controller model.
  31100. */
  31101. static MODEL_BASE_URL: string;
  31102. /**
  31103. * File name for the controller model.
  31104. */
  31105. static MODEL_FILENAME: string;
  31106. /**
  31107. * Creates a new ViveController from a gamepad
  31108. * @param vrGamepad the gamepad that the controller should be created from
  31109. */
  31110. constructor(vrGamepad: any);
  31111. /**
  31112. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31113. * @param scene scene in which to add meshes
  31114. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31115. */
  31116. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31117. /**
  31118. * Fired when the left button on this controller is modified
  31119. */
  31120. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31121. /**
  31122. * Fired when the right button on this controller is modified
  31123. */
  31124. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31125. /**
  31126. * Fired when the menu button on this controller is modified
  31127. */
  31128. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31129. /**
  31130. * Called once for each button that changed state since the last frame
  31131. * Vive mapping:
  31132. * 0: touchpad
  31133. * 1: trigger
  31134. * 2: left AND right buttons
  31135. * 3: menu button
  31136. * @param buttonIdx Which button index changed
  31137. * @param state New state of the button
  31138. * @param changes Which properties on the state changed since last frame
  31139. */
  31140. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31141. }
  31142. }
  31143. declare module BABYLON {
  31144. /**
  31145. * Defines the WebVRController object that represents controllers tracked in 3D space
  31146. */
  31147. abstract class WebVRController extends PoseEnabledController {
  31148. /**
  31149. * Internal, the default controller model for the controller
  31150. */
  31151. protected _defaultModel: AbstractMesh;
  31152. /**
  31153. * Fired when the trigger state has changed
  31154. */
  31155. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31156. /**
  31157. * Fired when the main button state has changed
  31158. */
  31159. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31160. /**
  31161. * Fired when the secondary button state has changed
  31162. */
  31163. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31164. /**
  31165. * Fired when the pad state has changed
  31166. */
  31167. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  31168. /**
  31169. * Fired when controllers stick values have changed
  31170. */
  31171. onPadValuesChangedObservable: Observable<StickValues>;
  31172. /**
  31173. * Array of button availible on the controller
  31174. */
  31175. protected _buttons: Array<MutableGamepadButton>;
  31176. private _onButtonStateChange;
  31177. /**
  31178. * Fired when a controller button's state has changed
  31179. * @param callback the callback containing the button that was modified
  31180. */
  31181. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  31182. /**
  31183. * X and Y axis corrisponding to the controllers joystick
  31184. */
  31185. pad: StickValues;
  31186. /**
  31187. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  31188. */
  31189. hand: string;
  31190. /**
  31191. * The default controller model for the controller
  31192. */
  31193. readonly defaultModel: AbstractMesh;
  31194. /**
  31195. * Creates a new WebVRController from a gamepad
  31196. * @param vrGamepad the gamepad that the WebVRController should be created from
  31197. */
  31198. constructor(vrGamepad: any);
  31199. /**
  31200. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  31201. */
  31202. update(): void;
  31203. /**
  31204. * Function to be called when a button is modified
  31205. */
  31206. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31207. /**
  31208. * Loads a mesh and attaches it to the controller
  31209. * @param scene the scene the mesh should be added to
  31210. * @param meshLoaded callback for when the mesh has been loaded
  31211. */
  31212. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31213. private _setButtonValue(newState, currentState, buttonIndex);
  31214. private _changes;
  31215. private _checkChanges(newState, currentState);
  31216. /**
  31217. * Disposes of th webVRCOntroller
  31218. */
  31219. dispose(): void;
  31220. }
  31221. }
  31222. declare module BABYLON {
  31223. /**
  31224. * Defines the WindowsMotionController object that the state of the windows motion controller
  31225. */
  31226. class WindowsMotionController extends WebVRController {
  31227. /**
  31228. * The base url used to load the left and right controller models
  31229. */
  31230. static MODEL_BASE_URL: string;
  31231. /**
  31232. * The name of the left controller model file
  31233. */
  31234. static MODEL_LEFT_FILENAME: string;
  31235. /**
  31236. * The name of the right controller model file
  31237. */
  31238. static MODEL_RIGHT_FILENAME: string;
  31239. /**
  31240. * The controller name prefix for this controller type
  31241. */
  31242. static readonly GAMEPAD_ID_PREFIX: string;
  31243. /**
  31244. * The controller id pattern for this controller type
  31245. */
  31246. private static readonly GAMEPAD_ID_PATTERN;
  31247. private _loadedMeshInfo;
  31248. private readonly _mapping;
  31249. /**
  31250. * Fired when the trackpad on this controller is clicked
  31251. */
  31252. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  31253. /**
  31254. * Fired when the trackpad on this controller is modified
  31255. */
  31256. onTrackpadValuesChangedObservable: Observable<StickValues>;
  31257. /**
  31258. * The current x and y values of this controller's trackpad
  31259. */
  31260. trackpad: StickValues;
  31261. /**
  31262. * Creates a new WindowsMotionController from a gamepad
  31263. * @param vrGamepad the gamepad that the controller should be created from
  31264. */
  31265. constructor(vrGamepad: any);
  31266. /**
  31267. * Fired when the trigger on this controller is modified
  31268. */
  31269. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31270. /**
  31271. * Fired when the menu button on this controller is modified
  31272. */
  31273. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31274. /**
  31275. * Fired when the grip button on this controller is modified
  31276. */
  31277. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31278. /**
  31279. * Fired when the thumbstick button on this controller is modified
  31280. */
  31281. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31282. /**
  31283. * Fired when the touchpad button on this controller is modified
  31284. */
  31285. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31286. /**
  31287. * Fired when the touchpad values on this controller are modified
  31288. */
  31289. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  31290. /**
  31291. * Called once per frame by the engine.
  31292. */
  31293. update(): void;
  31294. /**
  31295. * Called once for each button that changed state since the last frame
  31296. * @param buttonIdx Which button index changed
  31297. * @param state New state of the button
  31298. * @param changes Which properties on the state changed since last frame
  31299. */
  31300. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31301. /**
  31302. * Moves the buttons on the controller mesh based on their current state
  31303. * @param buttonName the name of the button to move
  31304. * @param buttonValue the value of the button which determines the buttons new position
  31305. */
  31306. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  31307. /**
  31308. * Moves the axis on the controller mesh based on its current state
  31309. * @param axis the index of the axis
  31310. * @param axisValue the value of the axis which determines the meshes new position
  31311. * @hidden
  31312. */
  31313. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  31314. /**
  31315. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31316. * @param scene scene in which to add meshes
  31317. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31318. */
  31319. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  31320. /**
  31321. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  31322. * can be transformed by button presses and axes values, based on this._mapping.
  31323. *
  31324. * @param scene scene in which the meshes exist
  31325. * @param meshes list of meshes that make up the controller model to process
  31326. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  31327. */
  31328. private processModel(scene, meshes);
  31329. private createMeshInfo(rootNode);
  31330. /**
  31331. * Gets the ray of the controller in the direction the controller is pointing
  31332. * @param length the length the resulting ray should be
  31333. * @returns a ray in the direction the controller is pointing
  31334. */
  31335. getForwardRay(length?: number): Ray;
  31336. /**
  31337. * Disposes of the controller
  31338. */
  31339. dispose(): void;
  31340. }
  31341. }
  31342. declare module BABYLON {
  31343. /**
  31344. * Interface to implement to create a shadow generator compatible with BJS.
  31345. */
  31346. interface IShadowGenerator {
  31347. /**
  31348. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31349. * @returns The render target texture if present otherwise, null
  31350. */
  31351. getShadowMap(): Nullable<RenderTargetTexture>;
  31352. /**
  31353. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31354. * @returns The render target texture if the shadow map is present otherwise, null
  31355. */
  31356. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31357. /**
  31358. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31359. * @param subMesh The submesh we want to render in the shadow map
  31360. * @param useInstances Defines wether will draw in the map using instances
  31361. * @returns true if ready otherwise, false
  31362. */
  31363. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31364. /**
  31365. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31366. * @param defines Defines of the material we want to update
  31367. * @param lightIndex Index of the light in the enabled light list of the material
  31368. */
  31369. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  31370. /**
  31371. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31372. * defined in the generator but impacting the effect).
  31373. * It implies the unifroms available on the materials are the standard BJS ones.
  31374. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31375. * @param effect The effect we are binfing the information for
  31376. */
  31377. bindShadowLight(lightIndex: string, effect: Effect): void;
  31378. /**
  31379. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31380. * (eq to shadow prjection matrix * light transform matrix)
  31381. * @returns The transform matrix used to create the shadow map
  31382. */
  31383. getTransformMatrix(): Matrix;
  31384. /**
  31385. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31386. * Cube and 2D textures for instance.
  31387. */
  31388. recreateShadowMap(): void;
  31389. /**
  31390. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31391. * @param onCompiled Callback triggered at the and of the effects compilation
  31392. * @param options Sets of optional options forcing the compilation with different modes
  31393. */
  31394. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31395. useInstances: boolean;
  31396. }>): void;
  31397. /**
  31398. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31399. * @param options Sets of optional options forcing the compilation with different modes
  31400. * @returns A promise that resolves when the compilation completes
  31401. */
  31402. forceCompilationAsync(options?: Partial<{
  31403. useInstances: boolean;
  31404. }>): Promise<void>;
  31405. /**
  31406. * Serializes the shadow generator setup to a json object.
  31407. * @returns The serialized JSON object
  31408. */
  31409. serialize(): any;
  31410. /**
  31411. * Disposes the Shadow map and related Textures and effects.
  31412. */
  31413. dispose(): void;
  31414. }
  31415. /**
  31416. * Default implementation IShadowGenerator.
  31417. * This is the main object responsible of generating shadows in the framework.
  31418. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  31419. */
  31420. class ShadowGenerator implements IShadowGenerator {
  31421. /**
  31422. * Shadow generator mode None: no filtering applied.
  31423. */
  31424. static readonly FILTER_NONE: number;
  31425. /**
  31426. * Shadow generator mode ESM: Exponential Shadow Mapping.
  31427. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31428. */
  31429. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  31430. /**
  31431. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  31432. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  31433. */
  31434. static readonly FILTER_POISSONSAMPLING: number;
  31435. /**
  31436. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  31437. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31438. */
  31439. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  31440. /**
  31441. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  31442. * edge artifacts on steep falloff.
  31443. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31444. */
  31445. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  31446. /**
  31447. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  31448. * edge artifacts on steep falloff.
  31449. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31450. */
  31451. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  31452. /**
  31453. * Shadow generator mode PCF: Percentage Closer Filtering
  31454. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31455. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  31456. */
  31457. static readonly FILTER_PCF: number;
  31458. /**
  31459. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  31460. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31461. * Contact Hardening
  31462. */
  31463. static readonly FILTER_PCSS: number;
  31464. /**
  31465. * Reserved for PCF and PCSS
  31466. * Highest Quality.
  31467. *
  31468. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  31469. *
  31470. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  31471. */
  31472. static readonly QUALITY_HIGH: number;
  31473. /**
  31474. * Reserved for PCF and PCSS
  31475. * Good tradeoff for quality/perf cross devices
  31476. *
  31477. * Execute PCF on a 3*3 kernel.
  31478. *
  31479. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  31480. */
  31481. static readonly QUALITY_MEDIUM: number;
  31482. /**
  31483. * Reserved for PCF and PCSS
  31484. * The lowest quality but the fastest.
  31485. *
  31486. * Execute PCF on a 1*1 kernel.
  31487. *
  31488. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  31489. */
  31490. static readonly QUALITY_LOW: number;
  31491. private _bias;
  31492. /**
  31493. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  31494. */
  31495. /**
  31496. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  31497. */
  31498. bias: number;
  31499. private _normalBias;
  31500. /**
  31501. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31502. */
  31503. /**
  31504. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31505. */
  31506. normalBias: number;
  31507. private _blurBoxOffset;
  31508. /**
  31509. * Gets the blur box offset: offset applied during the blur pass.
  31510. * Only usefull if useKernelBlur = false
  31511. */
  31512. /**
  31513. * Sets the blur box offset: offset applied during the blur pass.
  31514. * Only usefull if useKernelBlur = false
  31515. */
  31516. blurBoxOffset: number;
  31517. private _blurScale;
  31518. /**
  31519. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  31520. * 2 means half of the size.
  31521. */
  31522. /**
  31523. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  31524. * 2 means half of the size.
  31525. */
  31526. blurScale: number;
  31527. private _blurKernel;
  31528. /**
  31529. * Gets the blur kernel: kernel size of the blur pass.
  31530. * Only usefull if useKernelBlur = true
  31531. */
  31532. /**
  31533. * Sets the blur kernel: kernel size of the blur pass.
  31534. * Only usefull if useKernelBlur = true
  31535. */
  31536. blurKernel: number;
  31537. private _useKernelBlur;
  31538. /**
  31539. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  31540. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31541. */
  31542. /**
  31543. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  31544. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31545. */
  31546. useKernelBlur: boolean;
  31547. private _depthScale;
  31548. /**
  31549. * Gets the depth scale used in ESM mode.
  31550. */
  31551. /**
  31552. * Sets the depth scale used in ESM mode.
  31553. * This can override the scale stored on the light.
  31554. */
  31555. depthScale: number;
  31556. private _filter;
  31557. /**
  31558. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  31559. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31560. */
  31561. /**
  31562. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  31563. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31564. */
  31565. filter: number;
  31566. /**
  31567. * Gets if the current filter is set to Poisson Sampling.
  31568. */
  31569. /**
  31570. * Sets the current filter to Poisson Sampling.
  31571. */
  31572. usePoissonSampling: boolean;
  31573. /**
  31574. * Gets if the current filter is set to VSM.
  31575. * DEPRECATED. Should use useExponentialShadowMap instead.
  31576. */
  31577. /**
  31578. * Sets the current filter is to VSM.
  31579. * DEPRECATED. Should use useExponentialShadowMap instead.
  31580. */
  31581. useVarianceShadowMap: boolean;
  31582. /**
  31583. * Gets if the current filter is set to blurred VSM.
  31584. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31585. */
  31586. /**
  31587. * Sets the current filter is to blurred VSM.
  31588. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31589. */
  31590. useBlurVarianceShadowMap: boolean;
  31591. /**
  31592. * Gets if the current filter is set to ESM.
  31593. */
  31594. /**
  31595. * Sets the current filter is to ESM.
  31596. */
  31597. useExponentialShadowMap: boolean;
  31598. /**
  31599. * Gets if the current filter is set to filtered ESM.
  31600. */
  31601. /**
  31602. * Gets if the current filter is set to filtered ESM.
  31603. */
  31604. useBlurExponentialShadowMap: boolean;
  31605. /**
  31606. * Gets if the current filter is set to "close ESM" (using the inverse of the
  31607. * exponential to prevent steep falloff artifacts).
  31608. */
  31609. /**
  31610. * Sets the current filter to "close ESM" (using the inverse of the
  31611. * exponential to prevent steep falloff artifacts).
  31612. */
  31613. useCloseExponentialShadowMap: boolean;
  31614. /**
  31615. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  31616. * exponential to prevent steep falloff artifacts).
  31617. */
  31618. /**
  31619. * Sets the current filter to filtered "close ESM" (using the inverse of the
  31620. * exponential to prevent steep falloff artifacts).
  31621. */
  31622. useBlurCloseExponentialShadowMap: boolean;
  31623. /**
  31624. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  31625. */
  31626. /**
  31627. * Sets the current filter to "PCF" (percentage closer filtering).
  31628. */
  31629. usePercentageCloserFiltering: boolean;
  31630. private _filteringQuality;
  31631. /**
  31632. * Gets the PCF or PCSS Quality.
  31633. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31634. */
  31635. /**
  31636. * Sets the PCF or PCSS Quality.
  31637. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31638. */
  31639. filteringQuality: number;
  31640. /**
  31641. * Gets if the current filter is set to "PCSS" (contact hardening).
  31642. */
  31643. /**
  31644. * Sets the current filter to "PCSS" (contact hardening).
  31645. */
  31646. useContactHardeningShadow: boolean;
  31647. private _contactHardeningLightSizeUVRatio;
  31648. /**
  31649. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31650. * Using a ratio helps keeping shape stability independently of the map size.
  31651. *
  31652. * It does not account for the light projection as it was having too much
  31653. * instability during the light setup or during light position changes.
  31654. *
  31655. * Only valid if useContactHardeningShadow is true.
  31656. */
  31657. /**
  31658. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31659. * Using a ratio helps keeping shape stability independently of the map size.
  31660. *
  31661. * It does not account for the light projection as it was having too much
  31662. * instability during the light setup or during light position changes.
  31663. *
  31664. * Only valid if useContactHardeningShadow is true.
  31665. */
  31666. contactHardeningLightSizeUVRatio: number;
  31667. private _darkness;
  31668. /**
  31669. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31670. * 0 means strongest and 1 would means no shadow.
  31671. * @returns the darkness.
  31672. */
  31673. getDarkness(): number;
  31674. /**
  31675. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  31676. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  31677. * @returns the shadow generator allowing fluent coding.
  31678. */
  31679. setDarkness(darkness: number): ShadowGenerator;
  31680. private _transparencyShadow;
  31681. /**
  31682. * Sets the ability to have transparent shadow (boolean).
  31683. * @param transparent True if transparent else False
  31684. * @returns the shadow generator allowing fluent coding
  31685. */
  31686. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  31687. private _shadowMap;
  31688. private _shadowMap2;
  31689. /**
  31690. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31691. * @returns The render target texture if present otherwise, null
  31692. */
  31693. getShadowMap(): Nullable<RenderTargetTexture>;
  31694. /**
  31695. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31696. * @returns The render target texture if the shadow map is present otherwise, null
  31697. */
  31698. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31699. /**
  31700. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31701. * @param mesh Mesh to add
  31702. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31703. * @returns the Shadow Generator itself
  31704. */
  31705. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31706. /**
  31707. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31708. * @param mesh Mesh to remove
  31709. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31710. * @returns the Shadow Generator itself
  31711. */
  31712. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31713. /**
  31714. * Controls the extent to which the shadows fade out at the edge of the frustum
  31715. * Used only by directionals and spots
  31716. */
  31717. frustumEdgeFalloff: number;
  31718. private _light;
  31719. /**
  31720. * Returns the associated light object.
  31721. * @returns the light generating the shadow
  31722. */
  31723. getLight(): IShadowLight;
  31724. /**
  31725. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31726. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31727. * It might on the other hand introduce peter panning.
  31728. */
  31729. forceBackFacesOnly: boolean;
  31730. private _scene;
  31731. private _lightDirection;
  31732. private _effect;
  31733. private _viewMatrix;
  31734. private _projectionMatrix;
  31735. private _transformMatrix;
  31736. private _cachedPosition;
  31737. private _cachedDirection;
  31738. private _cachedDefines;
  31739. private _currentRenderID;
  31740. private _boxBlurPostprocess;
  31741. private _kernelBlurXPostprocess;
  31742. private _kernelBlurYPostprocess;
  31743. private _blurPostProcesses;
  31744. private _mapSize;
  31745. private _currentFaceIndex;
  31746. private _currentFaceIndexCache;
  31747. private _textureType;
  31748. private _defaultTextureMatrix;
  31749. /**
  31750. * Creates a ShadowGenerator object.
  31751. * A ShadowGenerator is the required tool to use the shadows.
  31752. * Each light casting shadows needs to use its own ShadowGenerator.
  31753. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31754. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31755. * @param light The light object generating the shadows.
  31756. * @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.
  31757. */
  31758. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31759. private _initializeGenerator();
  31760. private _initializeShadowMap();
  31761. private _initializeBlurRTTAndPostProcesses();
  31762. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31763. private _renderSubMeshForShadowMap(subMesh);
  31764. private _applyFilterValues();
  31765. /**
  31766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31767. * @param onCompiled Callback triggered at the and of the effects compilation
  31768. * @param options Sets of optional options forcing the compilation with different modes
  31769. */
  31770. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31771. useInstances: boolean;
  31772. }>): void;
  31773. /**
  31774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31775. * @param options Sets of optional options forcing the compilation with different modes
  31776. * @returns A promise that resolves when the compilation completes
  31777. */
  31778. forceCompilationAsync(options?: Partial<{
  31779. useInstances: boolean;
  31780. }>): Promise<void>;
  31781. /**
  31782. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31783. * @param subMesh The submesh we want to render in the shadow map
  31784. * @param useInstances Defines wether will draw in the map using instances
  31785. * @returns true if ready otherwise, false
  31786. */
  31787. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31788. /**
  31789. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31790. * @param defines Defines of the material we want to update
  31791. * @param lightIndex Index of the light in the enabled light list of the material
  31792. */
  31793. prepareDefines(defines: any, lightIndex: number): void;
  31794. /**
  31795. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31796. * defined in the generator but impacting the effect).
  31797. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31798. * @param effect The effect we are binfing the information for
  31799. */
  31800. bindShadowLight(lightIndex: string, effect: Effect): void;
  31801. /**
  31802. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31803. * (eq to shadow prjection matrix * light transform matrix)
  31804. * @returns The transform matrix used to create the shadow map
  31805. */
  31806. getTransformMatrix(): Matrix;
  31807. /**
  31808. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31809. * Cube and 2D textures for instance.
  31810. */
  31811. recreateShadowMap(): void;
  31812. private _disposeBlurPostProcesses();
  31813. private _disposeRTTandPostProcesses();
  31814. /**
  31815. * Disposes the ShadowGenerator.
  31816. * Returns nothing.
  31817. */
  31818. dispose(): void;
  31819. /**
  31820. * Serializes the shadow generator setup to a json object.
  31821. * @returns The serialized JSON object
  31822. */
  31823. serialize(): any;
  31824. /**
  31825. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31826. * @param parsedShadowGenerator The JSON object to parse
  31827. * @param scene The scene to create the shadow map for
  31828. * @returns The parsed shadow generator
  31829. */
  31830. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31831. }
  31832. }
  31833. declare module BABYLON {
  31834. }
  31835. declare module BABYLON {
  31836. /**
  31837. * Background material used to create an efficient environement around your scene.
  31838. */
  31839. class BackgroundMaterial extends PushMaterial {
  31840. /**
  31841. * Standard reflectance value at parallel view angle.
  31842. */
  31843. static StandardReflectance0: number;
  31844. /**
  31845. * Standard reflectance value at grazing angle.
  31846. */
  31847. static StandardReflectance90: number;
  31848. protected _primaryColor: Color3;
  31849. /**
  31850. * Key light Color (multiply against the environement texture)
  31851. */
  31852. primaryColor: Color3;
  31853. protected __perceptualColor: Nullable<Color3>;
  31854. /**
  31855. * Experimental Internal Use Only.
  31856. *
  31857. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31858. * This acts as a helper to set the primary color to a more "human friendly" value.
  31859. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31860. * output color as close as possible from the chosen value.
  31861. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31862. * part of lighting setup.)
  31863. */
  31864. _perceptualColor: Nullable<Color3>;
  31865. protected _primaryColorShadowLevel: float;
  31866. /**
  31867. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31868. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31869. */
  31870. primaryColorShadowLevel: float;
  31871. protected _primaryColorHighlightLevel: float;
  31872. /**
  31873. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31874. * The primary color is used at the level chosen to define what the white area would look.
  31875. */
  31876. primaryColorHighlightLevel: float;
  31877. protected _reflectionTexture: Nullable<BaseTexture>;
  31878. /**
  31879. * Reflection Texture used in the material.
  31880. * Should be author in a specific way for the best result (refer to the documentation).
  31881. */
  31882. reflectionTexture: Nullable<BaseTexture>;
  31883. protected _reflectionBlur: float;
  31884. /**
  31885. * Reflection Texture level of blur.
  31886. *
  31887. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31888. * texture twice.
  31889. */
  31890. reflectionBlur: float;
  31891. protected _diffuseTexture: Nullable<BaseTexture>;
  31892. /**
  31893. * Diffuse Texture used in the material.
  31894. * Should be author in a specific way for the best result (refer to the documentation).
  31895. */
  31896. diffuseTexture: Nullable<BaseTexture>;
  31897. protected _shadowLights: Nullable<IShadowLight[]>;
  31898. /**
  31899. * Specify the list of lights casting shadow on the material.
  31900. * All scene shadow lights will be included if null.
  31901. */
  31902. shadowLights: Nullable<IShadowLight[]>;
  31903. protected _shadowLevel: float;
  31904. /**
  31905. * Helps adjusting the shadow to a softer level if required.
  31906. * 0 means black shadows and 1 means no shadows.
  31907. */
  31908. shadowLevel: float;
  31909. protected _sceneCenter: Vector3;
  31910. /**
  31911. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31912. * It is usually zero but might be interesting to modify according to your setup.
  31913. */
  31914. sceneCenter: Vector3;
  31915. protected _opacityFresnel: boolean;
  31916. /**
  31917. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31918. * This helps ensuring a nice transition when the camera goes under the ground.
  31919. */
  31920. opacityFresnel: boolean;
  31921. protected _reflectionFresnel: boolean;
  31922. /**
  31923. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31924. * This helps adding a mirror texture on the ground.
  31925. */
  31926. reflectionFresnel: boolean;
  31927. protected _reflectionFalloffDistance: number;
  31928. /**
  31929. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31930. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31931. */
  31932. reflectionFalloffDistance: number;
  31933. protected _reflectionAmount: number;
  31934. /**
  31935. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31936. */
  31937. reflectionAmount: number;
  31938. protected _reflectionReflectance0: number;
  31939. /**
  31940. * This specifies the weight of the reflection at grazing angle.
  31941. */
  31942. reflectionReflectance0: number;
  31943. protected _reflectionReflectance90: number;
  31944. /**
  31945. * This specifies the weight of the reflection at a perpendicular point of view.
  31946. */
  31947. reflectionReflectance90: number;
  31948. /**
  31949. * Sets the reflection reflectance fresnel values according to the default standard
  31950. * empirically know to work well :-)
  31951. */
  31952. reflectionStandardFresnelWeight: number;
  31953. protected _useRGBColor: boolean;
  31954. /**
  31955. * Helps to directly use the maps channels instead of their level.
  31956. */
  31957. useRGBColor: boolean;
  31958. protected _enableNoise: boolean;
  31959. /**
  31960. * This helps reducing the banding effect that could occur on the background.
  31961. */
  31962. enableNoise: boolean;
  31963. /**
  31964. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31965. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31966. * Recommended to be keep at 1.0 except for special cases.
  31967. */
  31968. fovMultiplier: number;
  31969. private _fovMultiplier;
  31970. /**
  31971. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31972. */
  31973. useEquirectangularFOV: boolean;
  31974. private _maxSimultaneousLights;
  31975. /**
  31976. * Number of Simultaneous lights allowed on the material.
  31977. */
  31978. maxSimultaneousLights: int;
  31979. /**
  31980. * Default configuration related to image processing available in the Background Material.
  31981. */
  31982. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31983. /**
  31984. * Keep track of the image processing observer to allow dispose and replace.
  31985. */
  31986. private _imageProcessingObserver;
  31987. /**
  31988. * Attaches a new image processing configuration to the PBR Material.
  31989. * @param configuration (if null the scene configuration will be use)
  31990. */
  31991. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31992. /**
  31993. * Gets the image processing configuration used either in this material.
  31994. */
  31995. /**
  31996. * Sets the Default image processing configuration used either in the this material.
  31997. *
  31998. * If sets to null, the scene one is in use.
  31999. */
  32000. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  32001. /**
  32002. * Gets wether the color curves effect is enabled.
  32003. */
  32004. /**
  32005. * Sets wether the color curves effect is enabled.
  32006. */
  32007. cameraColorCurvesEnabled: boolean;
  32008. /**
  32009. * Gets wether the color grading effect is enabled.
  32010. */
  32011. /**
  32012. * Gets wether the color grading effect is enabled.
  32013. */
  32014. cameraColorGradingEnabled: boolean;
  32015. /**
  32016. * Gets wether tonemapping is enabled or not.
  32017. */
  32018. /**
  32019. * Sets wether tonemapping is enabled or not
  32020. */
  32021. cameraToneMappingEnabled: boolean;
  32022. /**
  32023. * The camera exposure used on this material.
  32024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32025. * This corresponds to a photographic exposure.
  32026. */
  32027. /**
  32028. * The camera exposure used on this material.
  32029. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32030. * This corresponds to a photographic exposure.
  32031. */
  32032. cameraExposure: float;
  32033. /**
  32034. * Gets The camera contrast used on this material.
  32035. */
  32036. /**
  32037. * Sets The camera contrast used on this material.
  32038. */
  32039. cameraContrast: float;
  32040. /**
  32041. * Gets the Color Grading 2D Lookup Texture.
  32042. */
  32043. /**
  32044. * Sets the Color Grading 2D Lookup Texture.
  32045. */
  32046. cameraColorGradingTexture: Nullable<BaseTexture>;
  32047. /**
  32048. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32049. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32050. * 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;
  32051. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32052. */
  32053. /**
  32054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32056. * 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;
  32057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32058. */
  32059. cameraColorCurves: Nullable<ColorCurves>;
  32060. /**
  32061. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  32062. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  32063. */
  32064. switchToBGR: boolean;
  32065. private _renderTargets;
  32066. private _reflectionControls;
  32067. private _white;
  32068. private _primaryShadowColor;
  32069. private _primaryHighlightColor;
  32070. /**
  32071. * Instantiates a Background Material in the given scene
  32072. * @param name The friendly name of the material
  32073. * @param scene The scene to add the material to
  32074. */
  32075. constructor(name: string, scene: Scene);
  32076. /**
  32077. * The entire material has been created in order to prevent overdraw.
  32078. * @returns false
  32079. */
  32080. needAlphaTesting(): boolean;
  32081. /**
  32082. * The entire material has been created in order to prevent overdraw.
  32083. * @returns true if blending is enable
  32084. */
  32085. needAlphaBlending(): boolean;
  32086. /**
  32087. * Checks wether the material is ready to be rendered for a given mesh.
  32088. * @param mesh The mesh to render
  32089. * @param subMesh The submesh to check against
  32090. * @param useInstances Specify wether or not the material is used with instances
  32091. * @returns true if all the dependencies are ready (Textures, Effects...)
  32092. */
  32093. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32094. /**
  32095. * Compute the primary color according to the chosen perceptual color.
  32096. */
  32097. private _computePrimaryColorFromPerceptualColor();
  32098. /**
  32099. * Compute the highlights and shadow colors according to their chosen levels.
  32100. */
  32101. private _computePrimaryColors();
  32102. /**
  32103. * Build the uniform buffer used in the material.
  32104. */
  32105. buildUniformLayout(): void;
  32106. /**
  32107. * Unbind the material.
  32108. */
  32109. unbind(): void;
  32110. /**
  32111. * Bind only the world matrix to the material.
  32112. * @param world The world matrix to bind.
  32113. */
  32114. bindOnlyWorldMatrix(world: Matrix): void;
  32115. /**
  32116. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  32117. * @param world The world matrix to bind.
  32118. * @param subMesh The submesh to bind for.
  32119. */
  32120. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32121. /**
  32122. * Dispose the material.
  32123. * @param forceDisposeEffect Force disposal of the associated effect.
  32124. * @param forceDisposeTextures Force disposal of the associated textures.
  32125. */
  32126. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32127. /**
  32128. * Clones the material.
  32129. * @param name The cloned name.
  32130. * @returns The cloned material.
  32131. */
  32132. clone(name: string): BackgroundMaterial;
  32133. /**
  32134. * Serializes the current material to its JSON representation.
  32135. * @returns The JSON representation.
  32136. */
  32137. serialize(): any;
  32138. /**
  32139. * Gets the class name of the material
  32140. * @returns "BackgroundMaterial"
  32141. */
  32142. getClassName(): string;
  32143. /**
  32144. * Parse a JSON input to create back a background material.
  32145. * @param source The JSON data to parse
  32146. * @param scene The scene to create the parsed material in
  32147. * @param rootUrl The root url of the assets the material depends upon
  32148. * @returns the instantiated BackgroundMaterial.
  32149. */
  32150. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  32151. }
  32152. }
  32153. declare module BABYLON {
  32154. /**
  32155. * The Physically based material base class of BJS.
  32156. *
  32157. * This offers the main features of a standard PBR material.
  32158. * For more information, please refer to the documentation :
  32159. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32160. */
  32161. abstract class PBRBaseMaterial extends PushMaterial {
  32162. /**
  32163. * Intensity of the direct lights e.g. the four lights available in your scene.
  32164. * This impacts both the direct diffuse and specular highlights.
  32165. */
  32166. protected _directIntensity: number;
  32167. /**
  32168. * Intensity of the emissive part of the material.
  32169. * This helps controlling the emissive effect without modifying the emissive color.
  32170. */
  32171. protected _emissiveIntensity: number;
  32172. /**
  32173. * Intensity of the environment e.g. how much the environment will light the object
  32174. * either through harmonics for rough material or through the refelction for shiny ones.
  32175. */
  32176. protected _environmentIntensity: number;
  32177. /**
  32178. * This is a special control allowing the reduction of the specular highlights coming from the
  32179. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32180. */
  32181. protected _specularIntensity: number;
  32182. /**
  32183. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  32184. */
  32185. private _lightingInfos;
  32186. /**
  32187. * Debug Control allowing disabling the bump map on this material.
  32188. */
  32189. protected _disableBumpMap: boolean;
  32190. /**
  32191. * AKA Diffuse Texture in standard nomenclature.
  32192. */
  32193. protected _albedoTexture: BaseTexture;
  32194. /**
  32195. * AKA Occlusion Texture in other nomenclature.
  32196. */
  32197. protected _ambientTexture: BaseTexture;
  32198. /**
  32199. * AKA Occlusion Texture Intensity in other nomenclature.
  32200. */
  32201. protected _ambientTextureStrength: number;
  32202. /**
  32203. * Stores the alpha values in a texture.
  32204. */
  32205. protected _opacityTexture: BaseTexture;
  32206. /**
  32207. * Stores the reflection values in a texture.
  32208. */
  32209. protected _reflectionTexture: BaseTexture;
  32210. /**
  32211. * Stores the refraction values in a texture.
  32212. */
  32213. protected _refractionTexture: BaseTexture;
  32214. /**
  32215. * Stores the emissive values in a texture.
  32216. */
  32217. protected _emissiveTexture: BaseTexture;
  32218. /**
  32219. * AKA Specular texture in other nomenclature.
  32220. */
  32221. protected _reflectivityTexture: BaseTexture;
  32222. /**
  32223. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32224. */
  32225. protected _metallicTexture: BaseTexture;
  32226. /**
  32227. * Specifies the metallic scalar of the metallic/roughness workflow.
  32228. * Can also be used to scale the metalness values of the metallic texture.
  32229. */
  32230. protected _metallic: number;
  32231. /**
  32232. * Specifies the roughness scalar of the metallic/roughness workflow.
  32233. * Can also be used to scale the roughness values of the metallic texture.
  32234. */
  32235. protected _roughness: number;
  32236. /**
  32237. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32238. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32239. */
  32240. protected _microSurfaceTexture: BaseTexture;
  32241. /**
  32242. * Stores surface normal data used to displace a mesh in a texture.
  32243. */
  32244. protected _bumpTexture: BaseTexture;
  32245. /**
  32246. * Stores the pre-calculated light information of a mesh in a texture.
  32247. */
  32248. protected _lightmapTexture: BaseTexture;
  32249. /**
  32250. * The color of a material in ambient lighting.
  32251. */
  32252. protected _ambientColor: Color3;
  32253. /**
  32254. * AKA Diffuse Color in other nomenclature.
  32255. */
  32256. protected _albedoColor: Color3;
  32257. /**
  32258. * AKA Specular Color in other nomenclature.
  32259. */
  32260. protected _reflectivityColor: Color3;
  32261. /**
  32262. * The color applied when light is reflected from a material.
  32263. */
  32264. protected _reflectionColor: Color3;
  32265. /**
  32266. * The color applied when light is emitted from a material.
  32267. */
  32268. protected _emissiveColor: Color3;
  32269. /**
  32270. * AKA Glossiness in other nomenclature.
  32271. */
  32272. protected _microSurface: number;
  32273. /**
  32274. * source material index of refraction (IOR)' / 'destination material IOR.
  32275. */
  32276. protected _indexOfRefraction: number;
  32277. /**
  32278. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32279. */
  32280. protected _invertRefractionY: boolean;
  32281. /**
  32282. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32283. * Materials half opaque for instance using refraction could benefit from this control.
  32284. */
  32285. protected _linkRefractionWithTransparency: boolean;
  32286. /**
  32287. * Specifies that the material will use the light map as a show map.
  32288. */
  32289. protected _useLightmapAsShadowmap: boolean;
  32290. /**
  32291. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32292. * makes the reflect vector face the model (under horizon).
  32293. */
  32294. protected _useHorizonOcclusion: boolean;
  32295. /**
  32296. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32297. * too much the area relying on ambient texture to define their ambient occlusion.
  32298. */
  32299. protected _useRadianceOcclusion: boolean;
  32300. /**
  32301. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32302. */
  32303. protected _useAlphaFromAlbedoTexture: boolean;
  32304. /**
  32305. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32306. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32307. */
  32308. protected _useSpecularOverAlpha: boolean;
  32309. /**
  32310. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32311. */
  32312. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32313. /**
  32314. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32315. */
  32316. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  32317. /**
  32318. * Specifies if the metallic texture contains the roughness information in its green channel.
  32319. */
  32320. protected _useRoughnessFromMetallicTextureGreen: boolean;
  32321. /**
  32322. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32323. */
  32324. protected _useMetallnessFromMetallicTextureBlue: boolean;
  32325. /**
  32326. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32327. */
  32328. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  32329. /**
  32330. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32331. */
  32332. protected _useAmbientInGrayScale: boolean;
  32333. /**
  32334. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32335. * The material will try to infer what glossiness each pixel should be.
  32336. */
  32337. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  32338. /**
  32339. * BJS is using an harcoded light falloff based on a manually sets up range.
  32340. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32341. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32342. */
  32343. protected _usePhysicalLightFalloff: boolean;
  32344. /**
  32345. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32346. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32347. */
  32348. protected _useRadianceOverAlpha: boolean;
  32349. /**
  32350. * Allows using an object space normal map (instead of tangent space).
  32351. */
  32352. protected _useObjectSpaceNormalMap: boolean;
  32353. /**
  32354. * Allows using the bump map in parallax mode.
  32355. */
  32356. protected _useParallax: boolean;
  32357. /**
  32358. * Allows using the bump map in parallax occlusion mode.
  32359. */
  32360. protected _useParallaxOcclusion: boolean;
  32361. /**
  32362. * Controls the scale bias of the parallax mode.
  32363. */
  32364. protected _parallaxScaleBias: number;
  32365. /**
  32366. * If sets to true, disables all the lights affecting the material.
  32367. */
  32368. protected _disableLighting: boolean;
  32369. /**
  32370. * Number of Simultaneous lights allowed on the material.
  32371. */
  32372. protected _maxSimultaneousLights: number;
  32373. /**
  32374. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  32375. */
  32376. protected _invertNormalMapX: boolean;
  32377. /**
  32378. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  32379. */
  32380. protected _invertNormalMapY: boolean;
  32381. /**
  32382. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32383. */
  32384. protected _twoSidedLighting: boolean;
  32385. /**
  32386. * Defines the alpha limits in alpha test mode.
  32387. */
  32388. protected _alphaCutOff: number;
  32389. /**
  32390. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32391. */
  32392. protected _forceAlphaTest: boolean;
  32393. /**
  32394. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32395. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32396. */
  32397. protected _useAlphaFresnel: boolean;
  32398. /**
  32399. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32400. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32401. */
  32402. protected _useLinearAlphaFresnel: boolean;
  32403. /**
  32404. * The transparency mode of the material.
  32405. */
  32406. protected _transparencyMode: Nullable<number>;
  32407. /**
  32408. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  32409. * from cos thetav and roughness:
  32410. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  32411. */
  32412. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  32413. /**
  32414. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32415. */
  32416. protected _forceIrradianceInFragment: boolean;
  32417. /**
  32418. * Force normal to face away from face.
  32419. */
  32420. protected _forceNormalForward: boolean;
  32421. /**
  32422. * Enables specular anti aliasing in the PBR shader.
  32423. * It will both interacts on the Geometry for analytical and IBL lighting.
  32424. * It also prefilter the roughness map based on the bump values.
  32425. */
  32426. protected _enableSpecularAntiAliasing: boolean;
  32427. /**
  32428. * Default configuration related to image processing available in the PBR Material.
  32429. */
  32430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32431. /**
  32432. * Keep track of the image processing observer to allow dispose and replace.
  32433. */
  32434. private _imageProcessingObserver;
  32435. /**
  32436. * Attaches a new image processing configuration to the PBR Material.
  32437. * @param configuration
  32438. */
  32439. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32440. /**
  32441. * Stores the available render targets.
  32442. */
  32443. private _renderTargets;
  32444. /**
  32445. * Sets the global ambient color for the material used in lighting calculations.
  32446. */
  32447. private _globalAmbientColor;
  32448. /**
  32449. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  32450. */
  32451. private _useLogarithmicDepth;
  32452. /**
  32453. * If set to true, no lighting calculations will be applied.
  32454. */
  32455. private _unlit;
  32456. /**
  32457. * Instantiates a new PBRMaterial instance.
  32458. *
  32459. * @param name The material name
  32460. * @param scene The scene the material will be use in.
  32461. */
  32462. constructor(name: string, scene: Scene);
  32463. /**
  32464. * Gets the name of the material class.
  32465. */
  32466. getClassName(): string;
  32467. /**
  32468. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32469. */
  32470. /**
  32471. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32472. */
  32473. useLogarithmicDepth: boolean;
  32474. /**
  32475. * Gets the current transparency mode.
  32476. */
  32477. /**
  32478. * Sets the transparency mode of the material.
  32479. *
  32480. * | Value | Type | Description |
  32481. * | ----- | ----------------------------------- | ----------- |
  32482. * | 0 | OPAQUE | |
  32483. * | 1 | ALPHATEST | |
  32484. * | 2 | ALPHABLEND | |
  32485. * | 3 | ALPHATESTANDBLEND | |
  32486. *
  32487. */
  32488. transparencyMode: Nullable<number>;
  32489. /**
  32490. * Returns true if alpha blending should be disabled.
  32491. */
  32492. private readonly _disableAlphaBlending;
  32493. /**
  32494. * Specifies whether or not this material should be rendered in alpha blend mode.
  32495. */
  32496. needAlphaBlending(): boolean;
  32497. /**
  32498. * Specifies if the mesh will require alpha blending.
  32499. * @param mesh - BJS mesh.
  32500. */
  32501. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32502. /**
  32503. * Specifies whether or not this material should be rendered in alpha test mode.
  32504. */
  32505. needAlphaTesting(): boolean;
  32506. /**
  32507. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32508. */
  32509. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32510. /**
  32511. * Gets the texture used for the alpha test.
  32512. */
  32513. getAlphaTestTexture(): BaseTexture;
  32514. /**
  32515. * Stores the reflectivity values based on metallic roughness workflow.
  32516. */
  32517. private static _scaledReflectivity;
  32518. /**
  32519. * Specifies that the submesh is ready to be used.
  32520. * @param mesh - BJS mesh.
  32521. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32522. * @param useInstances - Specifies that instances should be used.
  32523. * @returns - boolean indicating that the submesh is ready or not.
  32524. */
  32525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32526. /**
  32527. * Specifies if the material uses metallic roughness workflow.
  32528. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32529. */
  32530. isMetallicWorkflow(): boolean;
  32531. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32532. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32533. /**
  32534. * Force shader compilation
  32535. */
  32536. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32537. clipPlane: boolean;
  32538. }>): void;
  32539. /**
  32540. * Initializes the uniform buffer layout for the shader.
  32541. */
  32542. buildUniformLayout(): void;
  32543. /**
  32544. * Unbinds the textures.
  32545. */
  32546. unbind(): void;
  32547. /**
  32548. * Binds the submesh data.
  32549. * @param world - The world matrix.
  32550. * @param mesh - The BJS mesh.
  32551. * @param subMesh - A submesh of the BJS mesh.
  32552. */
  32553. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32554. /**
  32555. * Returns the animatable textures.
  32556. * @returns - Array of animatable textures.
  32557. */
  32558. getAnimatables(): IAnimatable[];
  32559. /**
  32560. * Returns the texture used for reflections.
  32561. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32562. */
  32563. private _getReflectionTexture();
  32564. /**
  32565. * Returns the texture used for refraction or null if none is used.
  32566. * @returns - Refection texture if present. If no refraction texture and refraction
  32567. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32568. */
  32569. private _getRefractionTexture();
  32570. /**
  32571. * Disposes the resources of the material.
  32572. * @param forceDisposeEffect - Forces the disposal of effects.
  32573. * @param forceDisposeTextures - Forces the disposal of all textures.
  32574. */
  32575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32576. }
  32577. }
  32578. declare module BABYLON {
  32579. /**
  32580. * The Physically based simple base material of BJS.
  32581. *
  32582. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32583. * It is used as the base class for both the specGloss and metalRough conventions.
  32584. */
  32585. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32586. /**
  32587. * Number of Simultaneous lights allowed on the material.
  32588. */
  32589. maxSimultaneousLights: number;
  32590. /**
  32591. * If sets to true, disables all the lights affecting the material.
  32592. */
  32593. disableLighting: boolean;
  32594. /**
  32595. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32596. */
  32597. environmentTexture: BaseTexture;
  32598. /**
  32599. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32600. */
  32601. invertNormalMapX: boolean;
  32602. /**
  32603. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32604. */
  32605. invertNormalMapY: boolean;
  32606. /**
  32607. * Normal map used in the model.
  32608. */
  32609. normalTexture: BaseTexture;
  32610. /**
  32611. * Emissivie color used to self-illuminate the model.
  32612. */
  32613. emissiveColor: Color3;
  32614. /**
  32615. * Emissivie texture used to self-illuminate the model.
  32616. */
  32617. emissiveTexture: BaseTexture;
  32618. /**
  32619. * Occlusion Channel Strenght.
  32620. */
  32621. occlusionStrength: number;
  32622. /**
  32623. * Occlusion Texture of the material (adding extra occlusion effects).
  32624. */
  32625. occlusionTexture: BaseTexture;
  32626. /**
  32627. * Defines the alpha limits in alpha test mode.
  32628. */
  32629. alphaCutOff: number;
  32630. /**
  32631. * Gets the current double sided mode.
  32632. */
  32633. /**
  32634. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32635. */
  32636. doubleSided: boolean;
  32637. lightmapTexture: BaseTexture;
  32638. useLightmapAsShadowmap: boolean;
  32639. /**
  32640. * Return the active textures of the material.
  32641. */
  32642. getActiveTextures(): BaseTexture[];
  32643. hasTexture(texture: BaseTexture): boolean;
  32644. /**
  32645. * Instantiates a new PBRMaterial instance.
  32646. *
  32647. * @param name The material name
  32648. * @param scene The scene the material will be use in.
  32649. */
  32650. constructor(name: string, scene: Scene);
  32651. getClassName(): string;
  32652. }
  32653. }
  32654. declare module BABYLON {
  32655. /**
  32656. * The Physically based material of BJS.
  32657. *
  32658. * This offers the main features of a standard PBR material.
  32659. * For more information, please refer to the documentation :
  32660. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32661. */
  32662. class PBRMaterial extends PBRBaseMaterial {
  32663. private static _PBRMATERIAL_OPAQUE;
  32664. /**
  32665. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32666. */
  32667. static readonly PBRMATERIAL_OPAQUE: number;
  32668. /**
  32669. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32670. */
  32671. private static _PBRMATERIAL_ALPHATEST;
  32672. /**
  32673. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32674. */
  32675. static readonly PBRMATERIAL_ALPHATEST: number;
  32676. /**
  32677. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32678. */
  32679. private static _PBRMATERIAL_ALPHABLEND;
  32680. /**
  32681. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32682. */
  32683. static readonly PBRMATERIAL_ALPHABLEND: number;
  32684. /**
  32685. * 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.
  32686. * They are also discarded below the alpha cutoff threshold to improve performances.
  32687. */
  32688. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  32689. /**
  32690. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32691. * They are also discarded below the alpha cutoff threshold to improve performances.
  32692. */
  32693. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  32694. /**
  32695. * Intensity of the direct lights e.g. the four lights available in your scene.
  32696. * This impacts both the direct diffuse and specular highlights.
  32697. */
  32698. directIntensity: number;
  32699. /**
  32700. * Intensity of the emissive part of the material.
  32701. * This helps controlling the emissive effect without modifying the emissive color.
  32702. */
  32703. emissiveIntensity: number;
  32704. /**
  32705. * Intensity of the environment e.g. how much the environment will light the object
  32706. * either through harmonics for rough material or through the refelction for shiny ones.
  32707. */
  32708. environmentIntensity: number;
  32709. /**
  32710. * This is a special control allowing the reduction of the specular highlights coming from the
  32711. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32712. */
  32713. specularIntensity: number;
  32714. /**
  32715. * Debug Control allowing disabling the bump map on this material.
  32716. */
  32717. disableBumpMap: boolean;
  32718. /**
  32719. * AKA Diffuse Texture in standard nomenclature.
  32720. */
  32721. albedoTexture: BaseTexture;
  32722. /**
  32723. * AKA Occlusion Texture in other nomenclature.
  32724. */
  32725. ambientTexture: BaseTexture;
  32726. /**
  32727. * AKA Occlusion Texture Intensity in other nomenclature.
  32728. */
  32729. ambientTextureStrength: number;
  32730. /**
  32731. * Stores the alpha values in a texture.
  32732. */
  32733. opacityTexture: BaseTexture;
  32734. /**
  32735. * Stores the reflection values in a texture.
  32736. */
  32737. reflectionTexture: Nullable<BaseTexture>;
  32738. /**
  32739. * Stores the emissive values in a texture.
  32740. */
  32741. emissiveTexture: BaseTexture;
  32742. /**
  32743. * AKA Specular texture in other nomenclature.
  32744. */
  32745. reflectivityTexture: BaseTexture;
  32746. /**
  32747. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32748. */
  32749. metallicTexture: BaseTexture;
  32750. /**
  32751. * Specifies the metallic scalar of the metallic/roughness workflow.
  32752. * Can also be used to scale the metalness values of the metallic texture.
  32753. */
  32754. metallic: number;
  32755. /**
  32756. * Specifies the roughness scalar of the metallic/roughness workflow.
  32757. * Can also be used to scale the roughness values of the metallic texture.
  32758. */
  32759. roughness: number;
  32760. /**
  32761. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32762. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32763. */
  32764. microSurfaceTexture: BaseTexture;
  32765. /**
  32766. * Stores surface normal data used to displace a mesh in a texture.
  32767. */
  32768. bumpTexture: BaseTexture;
  32769. /**
  32770. * Stores the pre-calculated light information of a mesh in a texture.
  32771. */
  32772. lightmapTexture: BaseTexture;
  32773. /**
  32774. * Stores the refracted light information in a texture.
  32775. */
  32776. refractionTexture: BaseTexture;
  32777. /**
  32778. * The color of a material in ambient lighting.
  32779. */
  32780. ambientColor: Color3;
  32781. /**
  32782. * AKA Diffuse Color in other nomenclature.
  32783. */
  32784. albedoColor: Color3;
  32785. /**
  32786. * AKA Specular Color in other nomenclature.
  32787. */
  32788. reflectivityColor: Color3;
  32789. /**
  32790. * The color reflected from the material.
  32791. */
  32792. reflectionColor: Color3;
  32793. /**
  32794. * The color emitted from the material.
  32795. */
  32796. emissiveColor: Color3;
  32797. /**
  32798. * AKA Glossiness in other nomenclature.
  32799. */
  32800. microSurface: number;
  32801. /**
  32802. * source material index of refraction (IOR)' / 'destination material IOR.
  32803. */
  32804. indexOfRefraction: number;
  32805. /**
  32806. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32807. */
  32808. invertRefractionY: boolean;
  32809. /**
  32810. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32811. * Materials half opaque for instance using refraction could benefit from this control.
  32812. */
  32813. linkRefractionWithTransparency: boolean;
  32814. useLightmapAsShadowmap: boolean;
  32815. /**
  32816. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32817. */
  32818. useAlphaFromAlbedoTexture: boolean;
  32819. /**
  32820. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32821. */
  32822. forceAlphaTest: boolean;
  32823. /**
  32824. * Defines the alpha limits in alpha test mode.
  32825. */
  32826. alphaCutOff: number;
  32827. /**
  32828. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32829. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32830. */
  32831. useSpecularOverAlpha: boolean;
  32832. /**
  32833. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32834. */
  32835. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32836. /**
  32837. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32838. */
  32839. useRoughnessFromMetallicTextureAlpha: boolean;
  32840. /**
  32841. * Specifies if the metallic texture contains the roughness information in its green channel.
  32842. */
  32843. useRoughnessFromMetallicTextureGreen: boolean;
  32844. /**
  32845. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32846. */
  32847. useMetallnessFromMetallicTextureBlue: boolean;
  32848. /**
  32849. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32850. */
  32851. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32852. /**
  32853. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32854. */
  32855. useAmbientInGrayScale: boolean;
  32856. /**
  32857. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32858. * The material will try to infer what glossiness each pixel should be.
  32859. */
  32860. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32861. /**
  32862. * BJS is using an harcoded light falloff based on a manually sets up range.
  32863. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32864. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32865. */
  32866. usePhysicalLightFalloff: boolean;
  32867. /**
  32868. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32869. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32870. */
  32871. useRadianceOverAlpha: boolean;
  32872. /**
  32873. * Allows using an object space normal map (instead of tangent space).
  32874. */
  32875. useObjectSpaceNormalMap: boolean;
  32876. /**
  32877. * Allows using the bump map in parallax mode.
  32878. */
  32879. useParallax: boolean;
  32880. /**
  32881. * Allows using the bump map in parallax occlusion mode.
  32882. */
  32883. useParallaxOcclusion: boolean;
  32884. /**
  32885. * Controls the scale bias of the parallax mode.
  32886. */
  32887. parallaxScaleBias: number;
  32888. /**
  32889. * If sets to true, disables all the lights affecting the material.
  32890. */
  32891. disableLighting: boolean;
  32892. /**
  32893. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32894. */
  32895. forceIrradianceInFragment: boolean;
  32896. /**
  32897. * Number of Simultaneous lights allowed on the material.
  32898. */
  32899. maxSimultaneousLights: number;
  32900. /**
  32901. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32902. */
  32903. invertNormalMapX: boolean;
  32904. /**
  32905. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32906. */
  32907. invertNormalMapY: boolean;
  32908. /**
  32909. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32910. */
  32911. twoSidedLighting: boolean;
  32912. /**
  32913. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32914. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32915. */
  32916. useAlphaFresnel: boolean;
  32917. /**
  32918. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32919. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32920. */
  32921. useLinearAlphaFresnel: boolean;
  32922. /**
  32923. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32924. * And/Or occlude the blended part.
  32925. */
  32926. environmentBRDFTexture: Nullable<BaseTexture>;
  32927. /**
  32928. * Force normal to face away from face.
  32929. */
  32930. forceNormalForward: boolean;
  32931. /**
  32932. * Enables specular anti aliasing in the PBR shader.
  32933. * It will both interacts on the Geometry for analytical and IBL lighting.
  32934. * It also prefilter the roughness map based on the bump values.
  32935. */
  32936. enableSpecularAntiAliasing: boolean;
  32937. /**
  32938. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32939. * makes the reflect vector face the model (under horizon).
  32940. */
  32941. useHorizonOcclusion: boolean;
  32942. /**
  32943. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32944. * too much the area relying on ambient texture to define their ambient occlusion.
  32945. */
  32946. useRadianceOcclusion: boolean;
  32947. /**
  32948. * If set to true, no lighting calculations will be applied.
  32949. */
  32950. unlit: boolean;
  32951. /**
  32952. * Gets the image processing configuration used either in this material.
  32953. */
  32954. /**
  32955. * Sets the Default image processing configuration used either in the this material.
  32956. *
  32957. * If sets to null, the scene one is in use.
  32958. */
  32959. imageProcessingConfiguration: ImageProcessingConfiguration;
  32960. /**
  32961. * Gets wether the color curves effect is enabled.
  32962. */
  32963. /**
  32964. * Sets wether the color curves effect is enabled.
  32965. */
  32966. cameraColorCurvesEnabled: boolean;
  32967. /**
  32968. * Gets wether the color grading effect is enabled.
  32969. */
  32970. /**
  32971. * Gets wether the color grading effect is enabled.
  32972. */
  32973. cameraColorGradingEnabled: boolean;
  32974. /**
  32975. * Gets wether tonemapping is enabled or not.
  32976. */
  32977. /**
  32978. * Sets wether tonemapping is enabled or not
  32979. */
  32980. cameraToneMappingEnabled: boolean;
  32981. /**
  32982. * The camera exposure used on this material.
  32983. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32984. * This corresponds to a photographic exposure.
  32985. */
  32986. /**
  32987. * The camera exposure used on this material.
  32988. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32989. * This corresponds to a photographic exposure.
  32990. */
  32991. cameraExposure: number;
  32992. /**
  32993. * Gets The camera contrast used on this material.
  32994. */
  32995. /**
  32996. * Sets The camera contrast used on this material.
  32997. */
  32998. cameraContrast: number;
  32999. /**
  33000. * Gets the Color Grading 2D Lookup Texture.
  33001. */
  33002. /**
  33003. * Sets the Color Grading 2D Lookup Texture.
  33004. */
  33005. cameraColorGradingTexture: Nullable<BaseTexture>;
  33006. /**
  33007. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33008. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33009. * 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;
  33010. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33011. */
  33012. /**
  33013. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33014. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33015. * 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;
  33016. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33017. */
  33018. cameraColorCurves: Nullable<ColorCurves>;
  33019. /**
  33020. * Instantiates a new PBRMaterial instance.
  33021. *
  33022. * @param name The material name
  33023. * @param scene The scene the material will be use in.
  33024. */
  33025. constructor(name: string, scene: Scene);
  33026. /**
  33027. * Returns the name of this material class.
  33028. */
  33029. getClassName(): string;
  33030. /**
  33031. * Returns an array of the actively used textures.
  33032. * @returns - Array of BaseTextures
  33033. */
  33034. getActiveTextures(): BaseTexture[];
  33035. /**
  33036. * Checks to see if a texture is used in the material.
  33037. * @param texture - Base texture to use.
  33038. * @returns - Boolean specifying if a texture is used in the material.
  33039. */
  33040. hasTexture(texture: BaseTexture): boolean;
  33041. /**
  33042. * Makes a duplicate of the current material.
  33043. * @param name - name to use for the new material.
  33044. */
  33045. clone(name: string): PBRMaterial;
  33046. /**
  33047. * Serializes this PBR Material.
  33048. * @returns - An object with the serialized material.
  33049. */
  33050. serialize(): any;
  33051. /**
  33052. * Parses a PBR Material from a serialized object.
  33053. * @param source - Serialized object.
  33054. * @param scene - BJS scene instance.
  33055. * @param rootUrl - url for the scene object
  33056. * @returns - PBRMaterial
  33057. */
  33058. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  33059. }
  33060. }
  33061. declare module BABYLON {
  33062. /**
  33063. * The PBR material of BJS following the metal roughness convention.
  33064. *
  33065. * This fits to the PBR convention in the GLTF definition:
  33066. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  33067. */
  33068. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  33069. /**
  33070. * The base color has two different interpretations depending on the value of metalness.
  33071. * When the material is a metal, the base color is the specific measured reflectance value
  33072. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  33073. * of the material.
  33074. */
  33075. baseColor: Color3;
  33076. /**
  33077. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  33078. * well as opacity information in the alpha channel.
  33079. */
  33080. baseTexture: BaseTexture;
  33081. /**
  33082. * Specifies the metallic scalar value of the material.
  33083. * Can also be used to scale the metalness values of the metallic texture.
  33084. */
  33085. metallic: number;
  33086. /**
  33087. * Specifies the roughness scalar value of the material.
  33088. * Can also be used to scale the roughness values of the metallic texture.
  33089. */
  33090. roughness: number;
  33091. /**
  33092. * Texture containing both the metallic value in the B channel and the
  33093. * roughness value in the G channel to keep better precision.
  33094. */
  33095. metallicRoughnessTexture: BaseTexture;
  33096. /**
  33097. * Instantiates a new PBRMetalRoughnessMaterial instance.
  33098. *
  33099. * @param name The material name
  33100. * @param scene The scene the material will be use in.
  33101. */
  33102. constructor(name: string, scene: Scene);
  33103. /**
  33104. * Return the currrent class name of the material.
  33105. */
  33106. getClassName(): string;
  33107. /**
  33108. * Return the active textures of the material.
  33109. */
  33110. getActiveTextures(): BaseTexture[];
  33111. /**
  33112. * Checks to see if a texture is used in the material.
  33113. * @param texture - Base texture to use.
  33114. * @returns - Boolean specifying if a texture is used in the material.
  33115. */
  33116. hasTexture(texture: BaseTexture): boolean;
  33117. /**
  33118. * Makes a duplicate of the current material.
  33119. * @param name - name to use for the new material.
  33120. */
  33121. clone(name: string): PBRMetallicRoughnessMaterial;
  33122. /**
  33123. * Serialize the material to a parsable JSON object.
  33124. */
  33125. serialize(): any;
  33126. /**
  33127. * Parses a JSON object correponding to the serialize function.
  33128. */
  33129. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  33130. }
  33131. }
  33132. declare module BABYLON {
  33133. /**
  33134. * The PBR material of BJS following the specular glossiness convention.
  33135. *
  33136. * This fits to the PBR convention in the GLTF definition:
  33137. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  33138. */
  33139. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  33140. /**
  33141. * Specifies the diffuse color of the material.
  33142. */
  33143. diffuseColor: Color3;
  33144. /**
  33145. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  33146. * channel.
  33147. */
  33148. diffuseTexture: BaseTexture;
  33149. /**
  33150. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  33151. */
  33152. specularColor: Color3;
  33153. /**
  33154. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  33155. */
  33156. glossiness: number;
  33157. /**
  33158. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  33159. */
  33160. specularGlossinessTexture: BaseTexture;
  33161. /**
  33162. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  33163. *
  33164. * @param name The material name
  33165. * @param scene The scene the material will be use in.
  33166. */
  33167. constructor(name: string, scene: Scene);
  33168. /**
  33169. * Return the currrent class name of the material.
  33170. */
  33171. getClassName(): string;
  33172. /**
  33173. * Return the active textures of the material.
  33174. */
  33175. getActiveTextures(): BaseTexture[];
  33176. /**
  33177. * Checks to see if a texture is used in the material.
  33178. * @param texture - Base texture to use.
  33179. * @returns - Boolean specifying if a texture is used in the material.
  33180. */
  33181. hasTexture(texture: BaseTexture): boolean;
  33182. /**
  33183. * Makes a duplicate of the current material.
  33184. * @param name - name to use for the new material.
  33185. */
  33186. clone(name: string): PBRSpecularGlossinessMaterial;
  33187. /**
  33188. * Serialize the material to a parsable JSON object.
  33189. */
  33190. serialize(): any;
  33191. /**
  33192. * Parses a JSON object correponding to the serialize function.
  33193. */
  33194. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  33195. }
  33196. }
  33197. declare module BABYLON {
  33198. class BaseTexture {
  33199. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33200. name: string;
  33201. private _hasAlpha;
  33202. hasAlpha: boolean;
  33203. getAlphaFromRGB: boolean;
  33204. level: number;
  33205. coordinatesIndex: number;
  33206. private _coordinatesMode;
  33207. /**
  33208. * How a texture is mapped.
  33209. *
  33210. * | Value | Type | Description |
  33211. * | ----- | ----------------------------------- | ----------- |
  33212. * | 0 | EXPLICIT_MODE | |
  33213. * | 1 | SPHERICAL_MODE | |
  33214. * | 2 | PLANAR_MODE | |
  33215. * | 3 | CUBIC_MODE | |
  33216. * | 4 | PROJECTION_MODE | |
  33217. * | 5 | SKYBOX_MODE | |
  33218. * | 6 | INVCUBIC_MODE | |
  33219. * | 7 | EQUIRECTANGULAR_MODE | |
  33220. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33221. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33222. */
  33223. coordinatesMode: number;
  33224. /**
  33225. * | Value | Type | Description |
  33226. * | ----- | ------------------ | ----------- |
  33227. * | 0 | CLAMP_ADDRESSMODE | |
  33228. * | 1 | WRAP_ADDRESSMODE | |
  33229. * | 2 | MIRROR_ADDRESSMODE | |
  33230. */
  33231. wrapU: number;
  33232. /**
  33233. * | Value | Type | Description |
  33234. * | ----- | ------------------ | ----------- |
  33235. * | 0 | CLAMP_ADDRESSMODE | |
  33236. * | 1 | WRAP_ADDRESSMODE | |
  33237. * | 2 | MIRROR_ADDRESSMODE | |
  33238. */
  33239. wrapV: number;
  33240. /**
  33241. * | Value | Type | Description |
  33242. * | ----- | ------------------ | ----------- |
  33243. * | 0 | CLAMP_ADDRESSMODE | |
  33244. * | 1 | WRAP_ADDRESSMODE | |
  33245. * | 2 | MIRROR_ADDRESSMODE | |
  33246. */
  33247. wrapR: number;
  33248. anisotropicFilteringLevel: number;
  33249. isCube: boolean;
  33250. is3D: boolean;
  33251. gammaSpace: boolean;
  33252. invertZ: boolean;
  33253. lodLevelInAlpha: boolean;
  33254. lodGenerationOffset: number;
  33255. lodGenerationScale: number;
  33256. isRenderTarget: boolean;
  33257. readonly uid: string;
  33258. toString(): string;
  33259. getClassName(): string;
  33260. animations: Animation[];
  33261. /**
  33262. * An event triggered when the texture is disposed.
  33263. */
  33264. onDisposeObservable: Observable<BaseTexture>;
  33265. private _onDisposeObserver;
  33266. onDispose: () => void;
  33267. delayLoadState: number;
  33268. private _scene;
  33269. _texture: Nullable<InternalTexture>;
  33270. private _uid;
  33271. readonly isBlocking: boolean;
  33272. constructor(scene: Nullable<Scene>);
  33273. getScene(): Nullable<Scene>;
  33274. getTextureMatrix(): Matrix;
  33275. getReflectionTextureMatrix(): Matrix;
  33276. getInternalTexture(): Nullable<InternalTexture>;
  33277. isReadyOrNotBlocking(): boolean;
  33278. isReady(): boolean;
  33279. getSize(): ISize;
  33280. getBaseSize(): ISize;
  33281. scale(ratio: number): void;
  33282. readonly canRescale: boolean;
  33283. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  33284. _rebuild(): void;
  33285. delayLoad(): void;
  33286. clone(): Nullable<BaseTexture>;
  33287. readonly textureType: number;
  33288. readonly textureFormat: number;
  33289. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  33290. releaseInternalTexture(): void;
  33291. sphericalPolynomial: Nullable<SphericalPolynomial>;
  33292. readonly _lodTextureHigh: Nullable<BaseTexture>;
  33293. readonly _lodTextureMid: Nullable<BaseTexture>;
  33294. readonly _lodTextureLow: Nullable<BaseTexture>;
  33295. dispose(): void;
  33296. serialize(): any;
  33297. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33298. }
  33299. }
  33300. declare module BABYLON {
  33301. /**
  33302. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  33303. * It can help converting any input color in a desired output one. This can then be used to create effects
  33304. * from sepia, black and white to sixties or futuristic rendering...
  33305. *
  33306. * The only supported format is currently 3dl.
  33307. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  33308. */
  33309. class ColorGradingTexture extends BaseTexture {
  33310. /**
  33311. * The current texture matrix. (will always be identity in color grading texture)
  33312. */
  33313. private _textureMatrix;
  33314. /**
  33315. * The texture URL.
  33316. */
  33317. url: string;
  33318. /**
  33319. * Empty line regex stored for GC.
  33320. */
  33321. private static _noneEmptyLineRegex;
  33322. private _engine;
  33323. /**
  33324. * Instantiates a ColorGradingTexture from the following parameters.
  33325. *
  33326. * @param url The location of the color gradind data (currently only supporting 3dl)
  33327. * @param scene The scene the texture will be used in
  33328. */
  33329. constructor(url: string, scene: Scene);
  33330. /**
  33331. * Returns the texture matrix used in most of the material.
  33332. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  33333. */
  33334. getTextureMatrix(): Matrix;
  33335. /**
  33336. * Occurs when the file being loaded is a .3dl LUT file.
  33337. */
  33338. private load3dlTexture();
  33339. /**
  33340. * Starts the loading process of the texture.
  33341. */
  33342. private loadTexture();
  33343. /**
  33344. * Clones the color gradind texture.
  33345. */
  33346. clone(): ColorGradingTexture;
  33347. /**
  33348. * Called during delayed load for textures.
  33349. */
  33350. delayLoad(): void;
  33351. /**
  33352. * Parses a color grading texture serialized by Babylon.
  33353. * @param parsedTexture The texture information being parsedTexture
  33354. * @param scene The scene to load the texture in
  33355. * @param rootUrl The root url of the data assets to load
  33356. * @return A color gradind texture
  33357. */
  33358. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  33359. /**
  33360. * Serializes the LUT texture to json format.
  33361. */
  33362. serialize(): any;
  33363. }
  33364. }
  33365. declare module BABYLON {
  33366. class CubeTexture extends BaseTexture {
  33367. url: string;
  33368. coordinatesMode: number;
  33369. /**
  33370. * Gets or sets the center of the bounding box associated with the cube texture
  33371. * It must define where the camera used to render the texture was set
  33372. */
  33373. boundingBoxPosition: Vector3;
  33374. private _boundingBoxSize;
  33375. /**
  33376. * Gets or sets the size of the bounding box associated with the cube texture
  33377. * When defined, the cubemap will switch to local mode
  33378. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33379. * @example https://www.babylonjs-playground.com/#RNASML
  33380. */
  33381. boundingBoxSize: Vector3;
  33382. protected _rotationY: number;
  33383. /**
  33384. * Gets texture matrix rotation angle around Y axis radians.
  33385. */
  33386. /**
  33387. * Sets texture matrix rotation angle around Y axis in radians.
  33388. */
  33389. rotationY: number;
  33390. private _noMipmap;
  33391. private _files;
  33392. private _extensions;
  33393. private _textureMatrix;
  33394. private _format;
  33395. private _prefiltered;
  33396. private _createPolynomials;
  33397. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  33398. /**
  33399. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  33400. * @param url defines the url of the prefiltered texture
  33401. * @param scene defines the scene the texture is attached to
  33402. * @param forcedExtension defines the extension of the file if different from the url
  33403. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33404. * @return the prefiltered texture
  33405. */
  33406. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  33407. /**
  33408. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  33409. * as prefiltered data.
  33410. * @param rootUrl defines the url of the texture or the root name of the six images
  33411. * @param scene defines the scene the texture is attached to
  33412. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  33413. * @param noMipmap defines if mipmaps should be created or not
  33414. * @param files defines the six files to load for the different faces
  33415. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  33416. * @param onError defines a callback triggered in case of error during load
  33417. * @param format defines the internal format to use for the texture once loaded
  33418. * @param prefiltered defines whether or not the texture is created from prefiltered data
  33419. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  33420. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33421. * @return the cube texture
  33422. */
  33423. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean);
  33424. delayLoad(): void;
  33425. getReflectionTextureMatrix(): Matrix;
  33426. setReflectionTextureMatrix(value: Matrix): void;
  33427. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  33428. clone(): CubeTexture;
  33429. }
  33430. }
  33431. declare module BABYLON {
  33432. /**
  33433. * A class extending {BABYLON.Texture} allowing drawing on a texture
  33434. * @see http://doc.babylonjs.com/how_to/dynamictexture
  33435. */
  33436. class DynamicTexture extends Texture {
  33437. private _generateMipMaps;
  33438. private _canvas;
  33439. private _context;
  33440. private _engine;
  33441. /**
  33442. * Creates a {BABYLON.DynamicTexture}
  33443. * @param name defines the name of the texture
  33444. * @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
  33445. * @param scene defines the scene where you want the texture
  33446. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  33447. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33448. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  33449. */
  33450. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  33451. /**
  33452. * Gets the current state of canRescale
  33453. */
  33454. readonly canRescale: boolean;
  33455. private _recreate(textureSize);
  33456. /**
  33457. * Scales the texture
  33458. * @param ratio the scale factor to apply to both width and height
  33459. */
  33460. scale(ratio: number): void;
  33461. /**
  33462. * Resizes the texture
  33463. * @param width the new width
  33464. * @param height the new height
  33465. */
  33466. scaleTo(width: number, height: number): void;
  33467. /**
  33468. * Gets the context of the canvas used by the texture
  33469. * @returns the canvas context of the dynamic texture
  33470. */
  33471. getContext(): CanvasRenderingContext2D;
  33472. /**
  33473. * Clears the texture
  33474. */
  33475. clear(): void;
  33476. /**
  33477. * Updates the texture
  33478. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33479. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  33480. */
  33481. update(invertY?: boolean, premulAlpha?: boolean): void;
  33482. /**
  33483. * Draws text onto the texture
  33484. * @param text defines the text to be drawn
  33485. * @param x defines the placement of the text from the left
  33486. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  33487. * @param font defines the font to be used with font-style, font-size, font-name
  33488. * @param color defines the color used for the text
  33489. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  33490. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33491. * @param update defines whether texture is immediately update (default is true)
  33492. */
  33493. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  33494. /**
  33495. * Clones the texture
  33496. * @returns the clone of the texture.
  33497. */
  33498. clone(): DynamicTexture;
  33499. /** @hidden */
  33500. _rebuild(): void;
  33501. }
  33502. }
  33503. declare module BABYLON {
  33504. /**
  33505. * This represents a texture coming from an HDR input.
  33506. *
  33507. * The only supported format is currently panorama picture stored in RGBE format.
  33508. * Example of such files can be found on HDRLib: http://hdrlib.com/
  33509. */
  33510. class HDRCubeTexture extends BaseTexture {
  33511. private static _facesMapping;
  33512. private _generateHarmonics;
  33513. private _noMipmap;
  33514. private _textureMatrix;
  33515. private _size;
  33516. private _onLoad;
  33517. private _onError;
  33518. /**
  33519. * The texture URL.
  33520. */
  33521. url: string;
  33522. /**
  33523. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  33524. */
  33525. coordinatesMode: number;
  33526. protected _isBlocking: boolean;
  33527. /**
  33528. * Gets wether or not the texture is blocking during loading.
  33529. */
  33530. /**
  33531. * Sets wether or not the texture is blocking during loading.
  33532. */
  33533. isBlocking: boolean;
  33534. protected _rotationY: number;
  33535. /**
  33536. * Gets texture matrix rotation angle around Y axis radians.
  33537. */
  33538. /**
  33539. * Sets texture matrix rotation angle around Y axis in radians.
  33540. */
  33541. rotationY: number;
  33542. /**
  33543. * Gets or sets the center of the bounding box associated with the cube texture
  33544. * It must define where the camera used to render the texture was set
  33545. */
  33546. boundingBoxPosition: Vector3;
  33547. private _boundingBoxSize;
  33548. /**
  33549. * Gets or sets the size of the bounding box associated with the cube texture
  33550. * When defined, the cubemap will switch to local mode
  33551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33552. * @example https://www.babylonjs-playground.com/#RNASML
  33553. */
  33554. boundingBoxSize: Vector3;
  33555. /**
  33556. * Instantiates an HDRTexture from the following parameters.
  33557. *
  33558. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  33559. * @param scene The scene the texture will be used in
  33560. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  33561. * @param noMipmap Forces to not generate the mipmap if true
  33562. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  33563. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  33564. * @param reserved Reserved flag for internal use.
  33565. */
  33566. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  33567. /**
  33568. * Occurs when the file is raw .hdr file.
  33569. */
  33570. private loadTexture();
  33571. clone(): HDRCubeTexture;
  33572. delayLoad(): void;
  33573. getReflectionTextureMatrix(): Matrix;
  33574. setReflectionTextureMatrix(value: Matrix): void;
  33575. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  33576. serialize(): any;
  33577. }
  33578. }
  33579. declare module BABYLON {
  33580. /**
  33581. * Class used to store data associated with WebGL texture data for the engine
  33582. * This class should not be used directly
  33583. */
  33584. class InternalTexture implements IInternalTextureTracker {
  33585. /**
  33586. * The source of the texture data is unknown
  33587. */
  33588. static DATASOURCE_UNKNOWN: number;
  33589. /**
  33590. * Texture data comes from an URL
  33591. */
  33592. static DATASOURCE_URL: number;
  33593. /**
  33594. * Texture data is only used for temporary storage
  33595. */
  33596. static DATASOURCE_TEMP: number;
  33597. /**
  33598. * Texture data comes from raw data (ArrayBuffer)
  33599. */
  33600. static DATASOURCE_RAW: number;
  33601. /**
  33602. * Texture content is dynamic (video or dynamic texture)
  33603. */
  33604. static DATASOURCE_DYNAMIC: number;
  33605. /**
  33606. * Texture content is generated by rendering to it
  33607. */
  33608. static DATASOURCE_RENDERTARGET: number;
  33609. /**
  33610. * Texture content is part of a multi render target process
  33611. */
  33612. static DATASOURCE_MULTIRENDERTARGET: number;
  33613. /**
  33614. * Texture data comes from a cube data file
  33615. */
  33616. static DATASOURCE_CUBE: number;
  33617. /**
  33618. * Texture data comes from a raw cube data
  33619. */
  33620. static DATASOURCE_CUBERAW: number;
  33621. /**
  33622. * Texture data come from a prefiltered cube data file
  33623. */
  33624. static DATASOURCE_CUBEPREFILTERED: number;
  33625. /**
  33626. * Texture content is raw 3D data
  33627. */
  33628. static DATASOURCE_RAW3D: number;
  33629. /**
  33630. * Texture content is a depth texture
  33631. */
  33632. static DATASOURCE_DEPTHTEXTURE: number;
  33633. /**
  33634. * Defines if the texture is ready
  33635. */
  33636. isReady: boolean;
  33637. /**
  33638. * Defines if the texture is a cube texture
  33639. */
  33640. isCube: boolean;
  33641. /**
  33642. * Defines if the texture contains 3D data
  33643. */
  33644. is3D: boolean;
  33645. /**
  33646. * Gets the URL used to load this texture
  33647. */
  33648. url: string;
  33649. /**
  33650. * Gets the sampling mode of the texture
  33651. */
  33652. samplingMode: number;
  33653. /**
  33654. * Gets a boolean indicating if the texture needs mipmaps generation
  33655. */
  33656. generateMipMaps: boolean;
  33657. /**
  33658. * Gets the number of samples used by the texture (WebGL2+ only)
  33659. */
  33660. samples: number;
  33661. /**
  33662. * Gets the type of the texture
  33663. */
  33664. type: number;
  33665. /**
  33666. * Gets the format of the texture
  33667. */
  33668. format: number;
  33669. /**
  33670. * Observable called when the texture is loaded
  33671. */
  33672. onLoadedObservable: Observable<InternalTexture>;
  33673. /**
  33674. * Gets the width of the texture
  33675. */
  33676. width: number;
  33677. /**
  33678. * Gets the height of the texture
  33679. */
  33680. height: number;
  33681. /**
  33682. * Gets the depth of the texture
  33683. */
  33684. depth: number;
  33685. /**
  33686. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33687. */
  33688. baseWidth: number;
  33689. /**
  33690. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33691. */
  33692. baseHeight: number;
  33693. /**
  33694. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33695. */
  33696. baseDepth: number;
  33697. /**
  33698. * Gets a boolean indicating if the texture is inverted on Y axis
  33699. */
  33700. invertY: boolean;
  33701. /**
  33702. * Gets or set the previous tracker in the list
  33703. */
  33704. previous: Nullable<IInternalTextureTracker>;
  33705. /**
  33706. * Gets or set the next tracker in the list
  33707. */
  33708. next: Nullable<IInternalTextureTracker>;
  33709. /** @hidden */
  33710. _initialSlot: number;
  33711. /** @hidden */
  33712. _designatedSlot: number;
  33713. /** @hidden */
  33714. _dataSource: number;
  33715. /** @hidden */
  33716. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  33717. /** @hidden */
  33718. _bufferView: Nullable<ArrayBufferView>;
  33719. /** @hidden */
  33720. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33721. /** @hidden */
  33722. _size: number;
  33723. /** @hidden */
  33724. _extension: string;
  33725. /** @hidden */
  33726. _files: Nullable<string[]>;
  33727. /** @hidden */
  33728. _workingCanvas: HTMLCanvasElement;
  33729. /** @hidden */
  33730. _workingContext: CanvasRenderingContext2D;
  33731. /** @hidden */
  33732. _framebuffer: Nullable<WebGLFramebuffer>;
  33733. /** @hidden */
  33734. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33735. /** @hidden */
  33736. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33737. /** @hidden */
  33738. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33739. /** @hidden */
  33740. _attachments: Nullable<number[]>;
  33741. /** @hidden */
  33742. _cachedCoordinatesMode: Nullable<number>;
  33743. /** @hidden */
  33744. _cachedWrapU: Nullable<number>;
  33745. /** @hidden */
  33746. _cachedWrapV: Nullable<number>;
  33747. /** @hidden */
  33748. _cachedWrapR: Nullable<number>;
  33749. /** @hidden */
  33750. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33751. /** @hidden */
  33752. _isDisabled: boolean;
  33753. /** @hidden */
  33754. _compression: Nullable<string>;
  33755. /** @hidden */
  33756. _generateStencilBuffer: boolean;
  33757. /** @hidden */
  33758. _generateDepthBuffer: boolean;
  33759. /** @hidden */
  33760. _comparisonFunction: number;
  33761. /** @hidden */
  33762. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33763. /** @hidden */
  33764. _lodGenerationScale: number;
  33765. /** @hidden */
  33766. _lodGenerationOffset: number;
  33767. /** @hidden */
  33768. _lodTextureHigh: BaseTexture;
  33769. /** @hidden */
  33770. _lodTextureMid: BaseTexture;
  33771. /** @hidden */
  33772. _lodTextureLow: BaseTexture;
  33773. /** @hidden */
  33774. _webGLTexture: Nullable<WebGLTexture>;
  33775. /** @hidden */
  33776. _references: number;
  33777. private _engine;
  33778. /**
  33779. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33780. */
  33781. readonly dataSource: number;
  33782. /**
  33783. * Creates a new InternalTexture
  33784. * @param engine defines the engine to use
  33785. * @param dataSource defines the type of data that will be used
  33786. */
  33787. constructor(engine: Engine, dataSource: number);
  33788. /**
  33789. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33790. */
  33791. incrementReferences(): void;
  33792. /**
  33793. * Change the size of the texture (not the size of the content)
  33794. * @param width defines the new width
  33795. * @param height defines the new height
  33796. * @param depth defines the new depth (1 by default)
  33797. */
  33798. updateSize(width: int, height: int, depth?: int): void;
  33799. /** @hidden */
  33800. _rebuild(): void;
  33801. private _swapAndDie(target);
  33802. /**
  33803. * Dispose the current allocated resources
  33804. */
  33805. dispose(): void;
  33806. }
  33807. }
  33808. declare module BABYLON {
  33809. /**
  33810. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33811. */
  33812. interface IInternalTextureTracker {
  33813. /**
  33814. * Gets or set the previous tracker in the list
  33815. */
  33816. previous: Nullable<IInternalTextureTracker>;
  33817. /**
  33818. * Gets or set the next tracker in the list
  33819. */
  33820. next: Nullable<IInternalTextureTracker>;
  33821. }
  33822. /**
  33823. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33824. */
  33825. class DummyInternalTextureTracker {
  33826. /**
  33827. * Gets or set the previous tracker in the list
  33828. */
  33829. previous: Nullable<IInternalTextureTracker>;
  33830. /**
  33831. * Gets or set the next tracker in the list
  33832. */
  33833. next: Nullable<IInternalTextureTracker>;
  33834. }
  33835. }
  33836. declare module BABYLON {
  33837. class MirrorTexture extends RenderTargetTexture {
  33838. private scene;
  33839. mirrorPlane: Plane;
  33840. private _transformMatrix;
  33841. private _mirrorMatrix;
  33842. private _savedViewMatrix;
  33843. private _blurX;
  33844. private _blurY;
  33845. private _adaptiveBlurKernel;
  33846. private _blurKernelX;
  33847. private _blurKernelY;
  33848. private _blurRatio;
  33849. blurRatio: number;
  33850. adaptiveBlurKernel: number;
  33851. blurKernel: number;
  33852. blurKernelX: number;
  33853. blurKernelY: number;
  33854. private _autoComputeBlurKernel();
  33855. protected _onRatioRescale(): void;
  33856. private _updateGammaSpace();
  33857. private _imageProcessingConfigChangeObserver;
  33858. constructor(name: string, size: number | {
  33859. width: number;
  33860. height: number;
  33861. } | {
  33862. ratio: number;
  33863. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33864. private _preparePostProcesses();
  33865. clone(): MirrorTexture;
  33866. serialize(): any;
  33867. dispose(): void;
  33868. }
  33869. }
  33870. declare module BABYLON {
  33871. interface IMultiRenderTargetOptions {
  33872. generateMipMaps?: boolean;
  33873. types?: number[];
  33874. samplingModes?: number[];
  33875. generateDepthBuffer?: boolean;
  33876. generateStencilBuffer?: boolean;
  33877. generateDepthTexture?: boolean;
  33878. textureCount?: number;
  33879. doNotChangeAspectRatio?: boolean;
  33880. defaultType?: number;
  33881. }
  33882. class MultiRenderTarget extends RenderTargetTexture {
  33883. private _internalTextures;
  33884. private _textures;
  33885. readonly isSupported: boolean;
  33886. private _multiRenderTargetOptions;
  33887. readonly textures: Texture[];
  33888. readonly depthTexture: Texture;
  33889. wrapU: number;
  33890. wrapV: number;
  33891. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33892. _rebuild(): void;
  33893. private _createInternalTextures();
  33894. private _createTextures();
  33895. samples: number;
  33896. resize(size: any): void;
  33897. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33898. dispose(): void;
  33899. releaseInternalTextures(): void;
  33900. }
  33901. }
  33902. declare module BABYLON {
  33903. class RawTexture extends Texture {
  33904. format: number;
  33905. private _engine;
  33906. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33907. update(data: ArrayBufferView): void;
  33908. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33909. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33910. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33911. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33912. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33913. }
  33914. }
  33915. declare module BABYLON {
  33916. /**
  33917. * Class used to store 3D textures containing user data
  33918. */
  33919. class RawTexture3D extends Texture {
  33920. /** Gets or sets the texture format to use */
  33921. format: number;
  33922. private _engine;
  33923. /**
  33924. * Create a new RawTexture3D
  33925. * @param data defines the data of the texture
  33926. * @param width defines the width of the texture
  33927. * @param height defines the height of the texture
  33928. * @param depth defines the depth of the texture
  33929. * @param format defines the texture format to use
  33930. * @param scene defines the hosting scene
  33931. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33932. * @param invertY defines if texture must be stored with Y axis inverted
  33933. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33934. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  33935. */
  33936. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33937. /** Gets or sets the texture format to use */
  33938. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  33939. /**
  33940. * Update the texture with new data
  33941. * @param data defines the data to store in the texture
  33942. */
  33943. update(data: ArrayBufferView): void;
  33944. }
  33945. }
  33946. declare module BABYLON {
  33947. /**
  33948. * Creates a refraction texture used by refraction channel of the standard material.
  33949. * @param name the texture name
  33950. * @param size size of the underlying texture
  33951. * @param scene root scene
  33952. */
  33953. class RefractionTexture extends RenderTargetTexture {
  33954. refractionPlane: Plane;
  33955. depth: number;
  33956. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33957. clone(): RefractionTexture;
  33958. serialize(): any;
  33959. }
  33960. }
  33961. declare module BABYLON {
  33962. class RenderTargetTexture extends Texture {
  33963. isCube: boolean;
  33964. static _REFRESHRATE_RENDER_ONCE: number;
  33965. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33966. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33967. static readonly REFRESHRATE_RENDER_ONCE: number;
  33968. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33969. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33970. /**
  33971. * Use this predicate to dynamically define the list of mesh you want to render.
  33972. * If set, the renderList property will be overwritten.
  33973. */
  33974. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33975. /**
  33976. * Use this list to define the list of mesh you want to render.
  33977. */
  33978. renderList: Nullable<Array<AbstractMesh>>;
  33979. renderParticles: boolean;
  33980. renderSprites: boolean;
  33981. coordinatesMode: number;
  33982. activeCamera: Nullable<Camera>;
  33983. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33984. useCameraPostProcesses: boolean;
  33985. ignoreCameraViewport: boolean;
  33986. private _postProcessManager;
  33987. private _postProcesses;
  33988. private _resizeObserver;
  33989. /**
  33990. * An event triggered when the texture is unbind.
  33991. */
  33992. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33993. /**
  33994. * An event triggered when the texture is unbind.
  33995. */
  33996. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33997. private _onAfterUnbindObserver;
  33998. onAfterUnbind: () => void;
  33999. /**
  34000. * An event triggered before rendering the texture
  34001. */
  34002. onBeforeRenderObservable: Observable<number>;
  34003. private _onBeforeRenderObserver;
  34004. onBeforeRender: (faceIndex: number) => void;
  34005. /**
  34006. * An event triggered after rendering the texture
  34007. */
  34008. onAfterRenderObservable: Observable<number>;
  34009. private _onAfterRenderObserver;
  34010. onAfterRender: (faceIndex: number) => void;
  34011. /**
  34012. * An event triggered after the texture clear
  34013. */
  34014. onClearObservable: Observable<Engine>;
  34015. private _onClearObserver;
  34016. onClear: (Engine: Engine) => void;
  34017. clearColor: Color4;
  34018. protected _size: number | {
  34019. width: number;
  34020. height: number;
  34021. };
  34022. protected _initialSizeParameter: number | {
  34023. width: number;
  34024. height: number;
  34025. } | {
  34026. ratio: number;
  34027. };
  34028. protected _sizeRatio: Nullable<number>;
  34029. _generateMipMaps: boolean;
  34030. protected _renderingManager: RenderingManager;
  34031. _waitingRenderList: string[];
  34032. protected _doNotChangeAspectRatio: boolean;
  34033. protected _currentRefreshId: number;
  34034. protected _refreshRate: number;
  34035. protected _textureMatrix: Matrix;
  34036. protected _samples: number;
  34037. protected _renderTargetOptions: RenderTargetCreationOptions;
  34038. readonly renderTargetOptions: RenderTargetCreationOptions;
  34039. protected _engine: Engine;
  34040. protected _onRatioRescale(): void;
  34041. /**
  34042. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  34043. * It must define where the camera used to render the texture is set
  34044. */
  34045. boundingBoxPosition: Vector3;
  34046. private _boundingBoxSize;
  34047. /**
  34048. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  34049. * When defined, the cubemap will switch to local mode
  34050. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34051. * @example https://www.babylonjs-playground.com/#RNASML
  34052. */
  34053. boundingBoxSize: Vector3;
  34054. /**
  34055. * In case the RTT has been created with a depth texture, get the associated
  34056. * depth texture.
  34057. * Otherwise, return null.
  34058. */
  34059. depthStencilTexture: Nullable<InternalTexture>;
  34060. /**
  34061. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  34062. * or used a shadow, depth texture...
  34063. * @param name The friendly name of the texture
  34064. * @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)
  34065. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  34066. * @param generateMipMaps True if mip maps need to be generated after render.
  34067. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  34068. * @param type The type of the buffer in the RTT (int, half float, float...)
  34069. * @param isCube True if a cube texture needs to be created
  34070. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  34071. * @param generateDepthBuffer True to generate a depth buffer
  34072. * @param generateStencilBuffer True to generate a stencil buffer
  34073. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  34074. */
  34075. constructor(name: string, size: number | {
  34076. width: number;
  34077. height: number;
  34078. } | {
  34079. ratio: number;
  34080. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  34081. /**
  34082. * Creates a depth stencil texture.
  34083. * This is only available in WebGL 2 or with the depth texture extension available.
  34084. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  34085. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  34086. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  34087. */
  34088. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  34089. private _processSizeParameter(size);
  34090. samples: number;
  34091. resetRefreshCounter(): void;
  34092. refreshRate: number;
  34093. addPostProcess(postProcess: PostProcess): void;
  34094. clearPostProcesses(dispose?: boolean): void;
  34095. removePostProcess(postProcess: PostProcess): void;
  34096. _shouldRender(): boolean;
  34097. getRenderSize(): number;
  34098. getRenderWidth(): number;
  34099. getRenderHeight(): number;
  34100. readonly canRescale: boolean;
  34101. scale(ratio: number): void;
  34102. getReflectionTextureMatrix(): Matrix;
  34103. resize(size: number | {
  34104. width: number;
  34105. height: number;
  34106. } | {
  34107. ratio: number;
  34108. }): void;
  34109. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  34110. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  34111. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34112. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  34113. /**
  34114. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34115. * This allowed control for front to back rendering or reversly depending of the special needs.
  34116. *
  34117. * @param renderingGroupId The rendering group id corresponding to its index
  34118. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34119. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34120. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34121. */
  34122. 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;
  34123. /**
  34124. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34125. *
  34126. * @param renderingGroupId The rendering group id corresponding to its index
  34127. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34128. */
  34129. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34130. clone(): RenderTargetTexture;
  34131. serialize(): any;
  34132. disposeFramebufferObjects(): void;
  34133. dispose(): void;
  34134. _rebuild(): void;
  34135. /**
  34136. * Clear the info related to rendering groups preventing retention point in material dispose.
  34137. */
  34138. freeRenderingGroups(): void;
  34139. }
  34140. }
  34141. declare module BABYLON {
  34142. class Texture extends BaseTexture {
  34143. static NEAREST_SAMPLINGMODE: number;
  34144. static NEAREST_NEAREST_MIPLINEAR: number;
  34145. static BILINEAR_SAMPLINGMODE: number;
  34146. static LINEAR_LINEAR_MIPNEAREST: number;
  34147. static TRILINEAR_SAMPLINGMODE: number;
  34148. static LINEAR_LINEAR_MIPLINEAR: number;
  34149. static NEAREST_NEAREST_MIPNEAREST: number;
  34150. static NEAREST_LINEAR_MIPNEAREST: number;
  34151. static NEAREST_LINEAR_MIPLINEAR: number;
  34152. static NEAREST_LINEAR: number;
  34153. static NEAREST_NEAREST: number;
  34154. static LINEAR_NEAREST_MIPNEAREST: number;
  34155. static LINEAR_NEAREST_MIPLINEAR: number;
  34156. static LINEAR_LINEAR: number;
  34157. static LINEAR_NEAREST: number;
  34158. static EXPLICIT_MODE: number;
  34159. static SPHERICAL_MODE: number;
  34160. static PLANAR_MODE: number;
  34161. static CUBIC_MODE: number;
  34162. static PROJECTION_MODE: number;
  34163. static SKYBOX_MODE: number;
  34164. static INVCUBIC_MODE: number;
  34165. static EQUIRECTANGULAR_MODE: number;
  34166. static FIXED_EQUIRECTANGULAR_MODE: number;
  34167. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34168. static CLAMP_ADDRESSMODE: number;
  34169. static WRAP_ADDRESSMODE: number;
  34170. static MIRROR_ADDRESSMODE: number;
  34171. /**
  34172. * 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
  34173. */
  34174. static UseSerializedUrlIfAny: boolean;
  34175. url: Nullable<string>;
  34176. uOffset: number;
  34177. vOffset: number;
  34178. uScale: number;
  34179. vScale: number;
  34180. uAng: number;
  34181. vAng: number;
  34182. wAng: number;
  34183. /**
  34184. * Defines the center of rotation (U)
  34185. */
  34186. uRotationCenter: number;
  34187. /**
  34188. * Defines the center of rotation (V)
  34189. */
  34190. vRotationCenter: number;
  34191. /**
  34192. * Defines the center of rotation (W)
  34193. */
  34194. wRotationCenter: number;
  34195. readonly noMipmap: boolean;
  34196. private _noMipmap;
  34197. _invertY: boolean;
  34198. private _rowGenerationMatrix;
  34199. private _cachedTextureMatrix;
  34200. private _projectionModeMatrix;
  34201. private _t0;
  34202. private _t1;
  34203. private _t2;
  34204. private _cachedUOffset;
  34205. private _cachedVOffset;
  34206. private _cachedUScale;
  34207. private _cachedVScale;
  34208. private _cachedUAng;
  34209. private _cachedVAng;
  34210. private _cachedWAng;
  34211. private _cachedProjectionMatrixId;
  34212. private _cachedCoordinatesMode;
  34213. _samplingMode: number;
  34214. /** @hidden */
  34215. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  34216. private _deleteBuffer;
  34217. protected _format: Nullable<number>;
  34218. private _delayedOnLoad;
  34219. private _delayedOnError;
  34220. protected _onLoadObservable: Nullable<Observable<Texture>>;
  34221. protected _isBlocking: boolean;
  34222. isBlocking: boolean;
  34223. readonly samplingMode: number;
  34224. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  34225. /**
  34226. * Update the url (and optional buffer) of this texture if url was null during construction.
  34227. * @param url the url of the texture
  34228. * @param buffer the buffer of the texture (defaults to null)
  34229. */
  34230. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  34231. delayLoad(): void;
  34232. updateSamplingMode(samplingMode: number): void;
  34233. private _prepareRowForTextureGeneration(x, y, z, t);
  34234. getTextureMatrix(): Matrix;
  34235. getReflectionTextureMatrix(): Matrix;
  34236. clone(): Texture;
  34237. readonly onLoadObservable: Observable<Texture>;
  34238. serialize(): any;
  34239. getClassName(): string;
  34240. dispose(): void;
  34241. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  34242. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  34243. 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;
  34244. }
  34245. }
  34246. declare module BABYLON {
  34247. /**
  34248. * Settings for finer control over video usage
  34249. */
  34250. interface VideoTextureSettings {
  34251. /**
  34252. * Applies `autoplay` to video, if specified
  34253. */
  34254. autoPlay?: boolean;
  34255. /**
  34256. * Applies `loop` to video, if specified
  34257. */
  34258. loop?: boolean;
  34259. /**
  34260. * Automatically updates internal texture from video at every frame in the render loop
  34261. */
  34262. autoUpdateTexture: boolean;
  34263. }
  34264. class VideoTexture extends Texture {
  34265. /**
  34266. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34267. */
  34268. readonly autoUpdateTexture: boolean;
  34269. /**
  34270. * The video instance used by the texture internally
  34271. */
  34272. readonly video: HTMLVideoElement;
  34273. private _generateMipMaps;
  34274. private _engine;
  34275. private _stillImageCaptured;
  34276. /**
  34277. * Creates a video texture.
  34278. * Sample : https://doc.babylonjs.com/how_to/video_texture
  34279. * @param {string | null} name optional name, will detect from video source, if not defined
  34280. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  34281. * @param {BABYLON.Scene} scene is obviously the current scene.
  34282. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34283. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  34284. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34285. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  34286. */
  34287. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34288. private _getName(src);
  34289. private _getVideo(src);
  34290. private _createInternalTexture;
  34291. private reset;
  34292. /**
  34293. * Internal method to initiate `update`.
  34294. */
  34295. _rebuild(): void;
  34296. /**
  34297. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34298. */
  34299. update(): void;
  34300. /**
  34301. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34302. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34303. */
  34304. updateTexture(isVisible: boolean): void;
  34305. protected _updateInternalTexture: (e?: Event | undefined) => void;
  34306. /**
  34307. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34308. * @param url New url.
  34309. */
  34310. updateURL(url: string): void;
  34311. dispose(): void;
  34312. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34313. minWidth: number;
  34314. maxWidth: number;
  34315. minHeight: number;
  34316. maxHeight: number;
  34317. deviceId: string;
  34318. }): void;
  34319. }
  34320. }
  34321. declare module BABYLON {
  34322. /**
  34323. * Particle emitter emitting particles from the inside of a box.
  34324. * It emits the particles randomly between 2 given directions.
  34325. */
  34326. class BoxParticleEmitter implements IParticleEmitterType {
  34327. /**
  34328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34329. */
  34330. direction1: Vector3;
  34331. /**
  34332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34333. */
  34334. direction2: Vector3;
  34335. /**
  34336. * 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.
  34337. */
  34338. minEmitBox: Vector3;
  34339. /**
  34340. * 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.
  34341. */
  34342. maxEmitBox: Vector3;
  34343. /**
  34344. * Creates a new instance BoxParticleEmitter
  34345. */
  34346. constructor();
  34347. /**
  34348. * Called by the particle System when the direction is computed for the created particle.
  34349. * @param emitPower is the power of the particle (speed)
  34350. * @param worldMatrix is the world matrix of the particle system
  34351. * @param directionToUpdate is the direction vector to update with the result
  34352. * @param particle is the particle we are computed the direction for
  34353. */
  34354. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34355. /**
  34356. * Called by the particle System when the position is computed for the created particle.
  34357. * @param worldMatrix is the world matrix of the particle system
  34358. * @param positionToUpdate is the position vector to update with the result
  34359. * @param particle is the particle we are computed the position for
  34360. */
  34361. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34362. /**
  34363. * Clones the current emitter and returns a copy of it
  34364. * @returns the new emitter
  34365. */
  34366. clone(): BoxParticleEmitter;
  34367. /**
  34368. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34369. * @param effect defines the update shader
  34370. */
  34371. applyToShader(effect: Effect): void;
  34372. /**
  34373. * Returns a string to use to update the GPU particles update shader
  34374. * @returns a string containng the defines string
  34375. */
  34376. getEffectDefines(): string;
  34377. /**
  34378. * Returns the string "BoxEmitter"
  34379. * @returns a string containing the class name
  34380. */
  34381. getClassName(): string;
  34382. /**
  34383. * Serializes the particle system to a JSON object.
  34384. * @returns the JSON object
  34385. */
  34386. serialize(): any;
  34387. /**
  34388. * Parse properties from a JSON object
  34389. * @param serializationObject defines the JSON object
  34390. */
  34391. parse(serializationObject: any): void;
  34392. }
  34393. }
  34394. declare module BABYLON {
  34395. /**
  34396. * Particle emitter emitting particles from the inside of a cone.
  34397. * It emits the particles alongside the cone volume from the base to the particle.
  34398. * The emission direction might be randomized.
  34399. */
  34400. class ConeParticleEmitter implements IParticleEmitterType {
  34401. /**
  34402. * The radius of the emission cone.
  34403. */
  34404. angle: number;
  34405. /**
  34406. * The cone base angle.
  34407. */
  34408. directionRandomizer: number;
  34409. private _radius;
  34410. private _height;
  34411. /**
  34412. * Gets the radius of the emission cone.
  34413. */
  34414. /**
  34415. * Sets the radius of the emission cone.
  34416. */
  34417. radius: number;
  34418. /**
  34419. * Creates a new instance ConeParticleEmitter
  34420. * @param radius the radius of the emission cone (1 by default)
  34421. * @param angles the cone base angle (PI by default)
  34422. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34423. */
  34424. constructor(radius?: number,
  34425. /**
  34426. * The radius of the emission cone.
  34427. */
  34428. angle?: number,
  34429. /**
  34430. * The cone base angle.
  34431. */
  34432. directionRandomizer?: number);
  34433. /**
  34434. * Called by the particle System when the direction is computed for the created particle.
  34435. * @param emitPower is the power of the particle (speed)
  34436. * @param worldMatrix is the world matrix of the particle system
  34437. * @param directionToUpdate is the direction vector to update with the result
  34438. * @param particle is the particle we are computed the direction for
  34439. */
  34440. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34441. /**
  34442. * Called by the particle System when the position is computed for the created particle.
  34443. * @param worldMatrix is the world matrix of the particle system
  34444. * @param positionToUpdate is the position vector to update with the result
  34445. * @param particle is the particle we are computed the position for
  34446. */
  34447. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34448. /**
  34449. * Clones the current emitter and returns a copy of it
  34450. * @returns the new emitter
  34451. */
  34452. clone(): ConeParticleEmitter;
  34453. /**
  34454. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34455. * @param effect defines the update shader
  34456. */
  34457. applyToShader(effect: Effect): void;
  34458. /**
  34459. * Returns a string to use to update the GPU particles update shader
  34460. * @returns a string containng the defines string
  34461. */
  34462. getEffectDefines(): string;
  34463. /**
  34464. * Returns the string "BoxEmitter"
  34465. * @returns a string containing the class name
  34466. */
  34467. getClassName(): string;
  34468. /**
  34469. * Serializes the particle system to a JSON object.
  34470. * @returns the JSON object
  34471. */
  34472. serialize(): any;
  34473. /**
  34474. * Parse properties from a JSON object
  34475. * @param serializationObject defines the JSON object
  34476. */
  34477. parse(serializationObject: any): void;
  34478. }
  34479. }
  34480. declare module BABYLON {
  34481. /**
  34482. * Particle emitter represents a volume emitting particles.
  34483. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  34484. */
  34485. interface IParticleEmitterType {
  34486. /**
  34487. * Called by the particle System when the direction is computed for the created particle.
  34488. * @param emitPower is the power of the particle (speed)
  34489. * @param worldMatrix is the world matrix of the particle system
  34490. * @param directionToUpdate is the direction vector to update with the result
  34491. * @param particle is the particle we are computed the direction for
  34492. */
  34493. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34494. /**
  34495. * Called by the particle System when the position is computed for the created particle.
  34496. * @param worldMatrix is the world matrix of the particle system
  34497. * @param positionToUpdate is the position vector to update with the result
  34498. * @param particle is the particle we are computed the position for
  34499. */
  34500. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34501. /**
  34502. * Clones the current emitter and returns a copy of it
  34503. * @returns the new emitter
  34504. */
  34505. clone(): IParticleEmitterType;
  34506. /**
  34507. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34508. * @param effect defines the update shader
  34509. */
  34510. applyToShader(effect: Effect): void;
  34511. /**
  34512. * Returns a string to use to update the GPU particles update shader
  34513. * @returns the effect defines string
  34514. */
  34515. getEffectDefines(): string;
  34516. /**
  34517. * Returns a string representing the class name
  34518. * @returns a string containing the class name
  34519. */
  34520. getClassName(): string;
  34521. /**
  34522. * Serializes the particle system to a JSON object.
  34523. * @returns the JSON object
  34524. */
  34525. serialize(): any;
  34526. /**
  34527. * Parse properties from a JSON object
  34528. * @param serializationObject defines the JSON object
  34529. */
  34530. parse(serializationObject: any): void;
  34531. }
  34532. }
  34533. declare module BABYLON {
  34534. /**
  34535. * Particle emitter emitting particles from the inside of a sphere.
  34536. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  34537. */
  34538. class SphereParticleEmitter implements IParticleEmitterType {
  34539. /**
  34540. * The radius of the emission sphere.
  34541. */
  34542. radius: number;
  34543. /**
  34544. * How much to randomize the particle direction [0-1].
  34545. */
  34546. directionRandomizer: number;
  34547. /**
  34548. * Creates a new instance SphereParticleEmitter
  34549. * @param radius the radius of the emission sphere (1 by default)
  34550. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34551. */
  34552. constructor(
  34553. /**
  34554. * The radius of the emission sphere.
  34555. */
  34556. radius?: number,
  34557. /**
  34558. * How much to randomize the particle direction [0-1].
  34559. */
  34560. directionRandomizer?: number);
  34561. /**
  34562. * Called by the particle System when the direction is computed for the created particle.
  34563. * @param emitPower is the power of the particle (speed)
  34564. * @param worldMatrix is the world matrix of the particle system
  34565. * @param directionToUpdate is the direction vector to update with the result
  34566. * @param particle is the particle we are computed the direction for
  34567. */
  34568. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34569. /**
  34570. * Called by the particle System when the position is computed for the created particle.
  34571. * @param worldMatrix is the world matrix of the particle system
  34572. * @param positionToUpdate is the position vector to update with the result
  34573. * @param particle is the particle we are computed the position for
  34574. */
  34575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34576. /**
  34577. * Clones the current emitter and returns a copy of it
  34578. * @returns the new emitter
  34579. */
  34580. clone(): SphereParticleEmitter;
  34581. /**
  34582. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34583. * @param effect defines the update shader
  34584. */
  34585. applyToShader(effect: Effect): void;
  34586. /**
  34587. * Returns a string to use to update the GPU particles update shader
  34588. * @returns a string containng the defines string
  34589. */
  34590. getEffectDefines(): string;
  34591. /**
  34592. * Returns the string "SphereParticleEmitter"
  34593. * @returns a string containing the class name
  34594. */
  34595. getClassName(): string;
  34596. /**
  34597. * Serializes the particle system to a JSON object.
  34598. * @returns the JSON object
  34599. */
  34600. serialize(): any;
  34601. /**
  34602. * Parse properties from a JSON object
  34603. * @param serializationObject defines the JSON object
  34604. */
  34605. parse(serializationObject: any): void;
  34606. }
  34607. /**
  34608. * Particle emitter emitting particles from the inside of a sphere.
  34609. * It emits the particles randomly between two vectors.
  34610. */
  34611. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  34612. /**
  34613. * The min limit of the emission direction.
  34614. */
  34615. direction1: Vector3;
  34616. /**
  34617. * The max limit of the emission direction.
  34618. */
  34619. direction2: Vector3;
  34620. /**
  34621. * Creates a new instance SphereDirectedParticleEmitter
  34622. * @param radius the radius of the emission sphere (1 by default)
  34623. * @param direction1 the min limit of the emission direction (up vector by default)
  34624. * @param direction2 the max limit of the emission direction (up vector by default)
  34625. */
  34626. constructor(radius?: number,
  34627. /**
  34628. * The min limit of the emission direction.
  34629. */
  34630. direction1?: Vector3,
  34631. /**
  34632. * The max limit of the emission direction.
  34633. */
  34634. direction2?: Vector3);
  34635. /**
  34636. * Called by the particle System when the direction is computed for the created particle.
  34637. * @param emitPower is the power of the particle (speed)
  34638. * @param worldMatrix is the world matrix of the particle system
  34639. * @param directionToUpdate is the direction vector to update with the result
  34640. * @param particle is the particle we are computed the direction for
  34641. */
  34642. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34643. /**
  34644. * Clones the current emitter and returns a copy of it
  34645. * @returns the new emitter
  34646. */
  34647. clone(): SphereDirectedParticleEmitter;
  34648. /**
  34649. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34650. * @param effect defines the update shader
  34651. */
  34652. applyToShader(effect: Effect): void;
  34653. /**
  34654. * Returns a string to use to update the GPU particles update shader
  34655. * @returns a string containng the defines string
  34656. */
  34657. getEffectDefines(): string;
  34658. /**
  34659. * Returns the string "SphereDirectedParticleEmitter"
  34660. * @returns a string containing the class name
  34661. */
  34662. getClassName(): string;
  34663. /**
  34664. * Serializes the particle system to a JSON object.
  34665. * @returns the JSON object
  34666. */
  34667. serialize(): any;
  34668. /**
  34669. * Parse properties from a JSON object
  34670. * @param serializationObject defines the JSON object
  34671. */
  34672. parse(serializationObject: any): void;
  34673. }
  34674. }
  34675. declare module BABYLON {
  34676. class CannonJSPlugin implements IPhysicsEnginePlugin {
  34677. private _useDeltaForWorldStep;
  34678. world: any;
  34679. name: string;
  34680. private _physicsMaterials;
  34681. private _fixedTimeStep;
  34682. BJSCANNON: any;
  34683. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  34684. setGravity(gravity: Vector3): void;
  34685. setTimeStep(timeStep: number): void;
  34686. getTimeStep(): number;
  34687. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34688. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34689. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34690. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34691. private _processChildMeshes(mainImpostor);
  34692. removePhysicsBody(impostor: PhysicsImpostor): void;
  34693. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34694. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34695. private _addMaterial(name, friction, restitution);
  34696. private _checkWithEpsilon(value);
  34697. private _createShape(impostor);
  34698. private _createHeightmap(object, pointDepth?);
  34699. private _minus90X;
  34700. private _plus90X;
  34701. private _tmpPosition;
  34702. private _tmpDeltaPosition;
  34703. private _tmpUnityRotation;
  34704. private _updatePhysicsBodyTransformation(impostor);
  34705. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34706. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34707. isSupported(): boolean;
  34708. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34709. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34710. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34711. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34712. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34713. getBodyMass(impostor: PhysicsImpostor): number;
  34714. getBodyFriction(impostor: PhysicsImpostor): number;
  34715. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34716. getBodyRestitution(impostor: PhysicsImpostor): number;
  34717. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34718. sleepBody(impostor: PhysicsImpostor): void;
  34719. wakeUpBody(impostor: PhysicsImpostor): void;
  34720. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34721. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  34722. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  34723. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34724. getRadius(impostor: PhysicsImpostor): number;
  34725. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34726. dispose(): void;
  34727. private _extendNamespace();
  34728. }
  34729. }
  34730. declare module BABYLON {
  34731. class OimoJSPlugin implements IPhysicsEnginePlugin {
  34732. world: any;
  34733. name: string;
  34734. BJSOIMO: any;
  34735. constructor(iterations?: number);
  34736. setGravity(gravity: Vector3): void;
  34737. setTimeStep(timeStep: number): void;
  34738. getTimeStep(): number;
  34739. private _tmpImpostorsArray;
  34740. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34741. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34742. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34743. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34744. private _tmpPositionVector;
  34745. removePhysicsBody(impostor: PhysicsImpostor): void;
  34746. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34747. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34748. isSupported(): boolean;
  34749. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34751. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34752. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34753. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34754. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34755. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34756. getBodyMass(impostor: PhysicsImpostor): number;
  34757. getBodyFriction(impostor: PhysicsImpostor): number;
  34758. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34759. getBodyRestitution(impostor: PhysicsImpostor): number;
  34760. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34761. sleepBody(impostor: PhysicsImpostor): void;
  34762. wakeUpBody(impostor: PhysicsImpostor): void;
  34763. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34764. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34765. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34766. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34767. getRadius(impostor: PhysicsImpostor): number;
  34768. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34769. dispose(): void;
  34770. }
  34771. }
  34772. declare var DracoDecoderModule: any;
  34773. declare var WebAssembly: any;
  34774. declare module BABYLON {
  34775. /**
  34776. * Configuration for Draco compression
  34777. */
  34778. interface IDracoCompressionConfiguration {
  34779. /**
  34780. * Configuration for the decoder.
  34781. */
  34782. decoder?: {
  34783. /**
  34784. * The url to the WebAssembly module.
  34785. */
  34786. wasmUrl?: string;
  34787. /**
  34788. * The url to the WebAssembly binary.
  34789. */
  34790. wasmBinaryUrl?: string;
  34791. /**
  34792. * The url to the fallback JavaScript module.
  34793. */
  34794. fallbackUrl?: string;
  34795. };
  34796. }
  34797. /**
  34798. * Draco compression (https://google.github.io/draco/)
  34799. *
  34800. * This class wraps the Draco module.
  34801. *
  34802. * **Encoder**
  34803. *
  34804. * The encoder is not currently implemented.
  34805. *
  34806. * **Decoder**
  34807. *
  34808. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  34809. *
  34810. * To update the configuration, use the following code:
  34811. * ```javascript
  34812. * BABYLON.DracoCompression.Configuration = {
  34813. * decoder: {
  34814. * wasmUrl: "<url to the WebAssembly library>",
  34815. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  34816. * fallbackUrl: "<url to the fallback JavaScript library>",
  34817. * }
  34818. * };
  34819. * ```
  34820. *
  34821. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  34822. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  34823. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  34824. *
  34825. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  34826. * ```javascript
  34827. * var dracoCompression = new BABYLON.DracoCompression();
  34828. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  34829. * [BABYLON.VertexBuffer.PositionKind]: 0
  34830. * });
  34831. * ```
  34832. *
  34833. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  34834. */
  34835. class DracoCompression implements IDisposable {
  34836. private static _DecoderModulePromise;
  34837. /**
  34838. * The configuration. Defaults to the following urls:
  34839. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  34840. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  34841. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  34842. */
  34843. static Configuration: IDracoCompressionConfiguration;
  34844. /**
  34845. * Returns true if the decoder is available.
  34846. */
  34847. static readonly DecoderAvailable: boolean;
  34848. /**
  34849. * Constructor
  34850. */
  34851. constructor();
  34852. /**
  34853. * Stop all async operations and release resources.
  34854. */
  34855. dispose(): void;
  34856. /**
  34857. * Decode Draco compressed mesh data to vertex data.
  34858. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  34859. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  34860. * @returns A promise that resolves with the decoded vertex data
  34861. */
  34862. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  34863. [kind: string]: number;
  34864. }): Promise<VertexData>;
  34865. private static _GetDecoderModule();
  34866. private static _LoadScriptAsync(url);
  34867. private static _LoadFileAsync(url);
  34868. }
  34869. }
  34870. declare module BABYLON {
  34871. /**
  34872. * This represents a set of one or more post processes in Babylon.
  34873. * A post process can be used to apply a shader to a texture after it is rendered.
  34874. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34875. */
  34876. class PostProcessRenderEffect {
  34877. private _postProcesses;
  34878. private _getPostProcesses;
  34879. private _singleInstance;
  34880. private _cameras;
  34881. private _indicesForCamera;
  34882. /**
  34883. * Name of the effect
  34884. */
  34885. _name: string;
  34886. /**
  34887. * Instantiates a post process render effect.
  34888. * A post process can be used to apply a shader to a texture after it is rendered.
  34889. * @param engine The engine the effect is tied to
  34890. * @param name The name of the effect
  34891. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34892. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34893. */
  34894. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34895. /**
  34896. * Checks if all the post processes in the effect are supported.
  34897. */
  34898. readonly isSupported: boolean;
  34899. /**
  34900. * Updates the current state of the effect
  34901. */
  34902. _update(): void;
  34903. /**
  34904. * Attaches the effect on cameras
  34905. * @param cameras The camera to attach to.
  34906. */
  34907. _attachCameras(cameras: Camera): void;
  34908. /**
  34909. * Attaches the effect on cameras
  34910. * @param cameras The camera to attach to.
  34911. */
  34912. _attachCameras(cameras: Camera[]): void;
  34913. /**
  34914. * Detatches the effect on cameras
  34915. * @param cameras The camera to detatch from.
  34916. */
  34917. _detachCameras(cameras: Camera): void;
  34918. /**
  34919. * Detatches the effect on cameras
  34920. * @param cameras The camera to detatch from.
  34921. */
  34922. _detachCameras(cameras: Camera[]): void;
  34923. /**
  34924. * Enables the effect on given cameras
  34925. * @param cameras The camera to enable.
  34926. */
  34927. _enable(cameras: Camera): void;
  34928. /**
  34929. * Enables the effect on given cameras
  34930. * @param cameras The camera to enable.
  34931. */
  34932. _enable(cameras: Nullable<Camera[]>): void;
  34933. /**
  34934. * Disables the effect on the given cameras
  34935. * @param cameras The camera to disable.
  34936. */
  34937. _disable(cameras: Camera): void;
  34938. /**
  34939. * Disables the effect on the given cameras
  34940. * @param cameras The camera to disable.
  34941. */
  34942. _disable(cameras: Nullable<Camera[]>): void;
  34943. /**
  34944. * Gets a list of the post processes contained in the effect.
  34945. * @param camera The camera to get the post processes on.
  34946. * @returns The list of the post processes in the effect.
  34947. */
  34948. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34949. }
  34950. }
  34951. declare module BABYLON {
  34952. class PostProcessRenderPipeline {
  34953. private engine;
  34954. private _renderEffects;
  34955. private _renderEffectsForIsolatedPass;
  34956. protected _cameras: Camera[];
  34957. _name: string;
  34958. constructor(engine: Engine, name: string);
  34959. getClassName(): string;
  34960. readonly isSupported: boolean;
  34961. addEffect(renderEffect: PostProcessRenderEffect): void;
  34962. _rebuild(): void;
  34963. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34964. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34965. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34966. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34967. _attachCameras(cameras: Camera, unique: boolean): void;
  34968. _attachCameras(cameras: Camera[], unique: boolean): void;
  34969. _detachCameras(cameras: Camera): void;
  34970. _detachCameras(cameras: Nullable<Camera[]>): void;
  34971. _update(): void;
  34972. _reset(): void;
  34973. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34974. dispose(): void;
  34975. }
  34976. }
  34977. declare module BABYLON {
  34978. class PostProcessRenderPipelineManager {
  34979. private _renderPipelines;
  34980. constructor();
  34981. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34982. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34983. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34984. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34985. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34986. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34987. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34988. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34989. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34990. update(): void;
  34991. _rebuild(): void;
  34992. dispose(): void;
  34993. }
  34994. }
  34995. declare module BABYLON {
  34996. /**
  34997. * Helper class dealing with the extraction of spherical polynomial dataArray
  34998. * from a cube map.
  34999. */
  35000. class CubeMapToSphericalPolynomialTools {
  35001. private static FileFaces;
  35002. /**
  35003. * Converts a texture to the according Spherical Polynomial data.
  35004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35005. *
  35006. * @param texture The texture to extract the information from.
  35007. * @return The Spherical Polynomial data.
  35008. */
  35009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  35010. /**
  35011. * Converts a cubemap to the according Spherical Polynomial data.
  35012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35013. *
  35014. * @param cubeInfo The Cube map to extract the information from.
  35015. * @return The Spherical Polynomial data.
  35016. */
  35017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  35018. }
  35019. }
  35020. declare module BABYLON {
  35021. /**
  35022. * Header information of HDR texture files.
  35023. */
  35024. interface HDRInfo {
  35025. /**
  35026. * The height of the texture in pixels.
  35027. */
  35028. height: number;
  35029. /**
  35030. * The width of the texture in pixels.
  35031. */
  35032. width: number;
  35033. /**
  35034. * The index of the beginning of the data in the binary file.
  35035. */
  35036. dataPosition: number;
  35037. }
  35038. /**
  35039. * This groups tools to convert HDR texture to native colors array.
  35040. */
  35041. class HDRTools {
  35042. private static Ldexp(mantissa, exponent);
  35043. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  35044. private static readStringLine(uint8array, startIndex);
  35045. /**
  35046. * Reads header information from an RGBE texture stored in a native array.
  35047. * More information on this format are available here:
  35048. * https://en.wikipedia.org/wiki/RGBE_image_format
  35049. *
  35050. * @param uint8array The binary file stored in native array.
  35051. * @return The header information.
  35052. */
  35053. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  35054. /**
  35055. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  35056. * This RGBE texture needs to store the information as a panorama.
  35057. *
  35058. * More information on this format are available here:
  35059. * https://en.wikipedia.org/wiki/RGBE_image_format
  35060. *
  35061. * @param buffer The binary file stored in an array buffer.
  35062. * @param size The expected size of the extracted cubemap.
  35063. * @return The Cube Map information.
  35064. */
  35065. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  35066. /**
  35067. * Returns the pixels data extracted from an RGBE texture.
  35068. * This pixels will be stored left to right up to down in the R G B order in one array.
  35069. *
  35070. * More information on this format are available here:
  35071. * https://en.wikipedia.org/wiki/RGBE_image_format
  35072. *
  35073. * @param uint8array The binary file stored in an array buffer.
  35074. * @param hdrInfo The header information of the file.
  35075. * @return The pixels data in RGB right to left up to down order.
  35076. */
  35077. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  35078. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  35079. }
  35080. }
  35081. declare module BABYLON {
  35082. /**
  35083. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  35084. */
  35085. interface CubeMapInfo {
  35086. /**
  35087. * The pixel array for the front face.
  35088. * This is stored in format, left to right, up to down format.
  35089. */
  35090. front: Nullable<ArrayBufferView>;
  35091. /**
  35092. * The pixel array for the back face.
  35093. * This is stored in format, left to right, up to down format.
  35094. */
  35095. back: Nullable<ArrayBufferView>;
  35096. /**
  35097. * The pixel array for the left face.
  35098. * This is stored in format, left to right, up to down format.
  35099. */
  35100. left: Nullable<ArrayBufferView>;
  35101. /**
  35102. * The pixel array for the right face.
  35103. * This is stored in format, left to right, up to down format.
  35104. */
  35105. right: Nullable<ArrayBufferView>;
  35106. /**
  35107. * The pixel array for the up face.
  35108. * This is stored in format, left to right, up to down format.
  35109. */
  35110. up: Nullable<ArrayBufferView>;
  35111. /**
  35112. * The pixel array for the down face.
  35113. * This is stored in format, left to right, up to down format.
  35114. */
  35115. down: Nullable<ArrayBufferView>;
  35116. /**
  35117. * The size of the cubemap stored.
  35118. *
  35119. * Each faces will be size * size pixels.
  35120. */
  35121. size: number;
  35122. /**
  35123. * The format of the texture.
  35124. *
  35125. * RGBA, RGB.
  35126. */
  35127. format: number;
  35128. /**
  35129. * The type of the texture data.
  35130. *
  35131. * UNSIGNED_INT, FLOAT.
  35132. */
  35133. type: number;
  35134. /**
  35135. * Specifies whether the texture is in gamma space.
  35136. */
  35137. gammaSpace: boolean;
  35138. }
  35139. /**
  35140. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  35141. */
  35142. class PanoramaToCubeMapTools {
  35143. private static FACE_FRONT;
  35144. private static FACE_BACK;
  35145. private static FACE_RIGHT;
  35146. private static FACE_LEFT;
  35147. private static FACE_DOWN;
  35148. private static FACE_UP;
  35149. /**
  35150. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  35151. *
  35152. * @param float32Array The source data.
  35153. * @param inputWidth The width of the input panorama.
  35154. * @param inputhHeight The height of the input panorama.
  35155. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  35156. * @return The cubemap data
  35157. */
  35158. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  35159. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  35160. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  35161. }
  35162. }
  35163. declare module BABYLON {
  35164. class CustomProceduralTexture extends ProceduralTexture {
  35165. private _animate;
  35166. private _time;
  35167. private _config;
  35168. private _texturePath;
  35169. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  35170. private loadJson(jsonUrl);
  35171. isReady(): boolean;
  35172. render(useCameraPostProcess?: boolean): void;
  35173. updateTextures(): void;
  35174. updateShaderUniforms(): void;
  35175. animate: boolean;
  35176. }
  35177. }
  35178. declare module BABYLON {
  35179. class ProceduralTexture extends Texture {
  35180. isCube: boolean;
  35181. private _size;
  35182. _generateMipMaps: boolean;
  35183. isEnabled: boolean;
  35184. private _currentRefreshId;
  35185. private _refreshRate;
  35186. onGenerated: () => void;
  35187. private _vertexBuffers;
  35188. private _indexBuffer;
  35189. private _effect;
  35190. private _uniforms;
  35191. private _samplers;
  35192. private _fragment;
  35193. _textures: {
  35194. [key: string]: Texture;
  35195. };
  35196. private _floats;
  35197. private _floatsArrays;
  35198. private _colors3;
  35199. private _colors4;
  35200. private _vectors2;
  35201. private _vectors3;
  35202. private _matrices;
  35203. private _fallbackTexture;
  35204. private _fallbackTextureUsed;
  35205. private _engine;
  35206. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  35207. private _createIndexBuffer();
  35208. _rebuild(): void;
  35209. reset(): void;
  35210. isReady(): boolean;
  35211. resetRefreshCounter(): void;
  35212. setFragment(fragment: any): void;
  35213. refreshRate: number;
  35214. _shouldRender(): boolean;
  35215. getRenderSize(): number;
  35216. resize(size: number, generateMipMaps: boolean): void;
  35217. private _checkUniform(uniformName);
  35218. setTexture(name: string, texture: Texture): ProceduralTexture;
  35219. setFloat(name: string, value: number): ProceduralTexture;
  35220. setFloats(name: string, value: number[]): ProceduralTexture;
  35221. setColor3(name: string, value: Color3): ProceduralTexture;
  35222. setColor4(name: string, value: Color4): ProceduralTexture;
  35223. setVector2(name: string, value: Vector2): ProceduralTexture;
  35224. setVector3(name: string, value: Vector3): ProceduralTexture;
  35225. setMatrix(name: string, value: Matrix): ProceduralTexture;
  35226. render(useCameraPostProcess?: boolean): void;
  35227. clone(): ProceduralTexture;
  35228. dispose(): void;
  35229. }
  35230. }
  35231. declare module BABYLON {
  35232. /**
  35233. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  35234. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  35235. */
  35236. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35237. private _scene;
  35238. private _originalCameras;
  35239. /**
  35240. * ID of the sharpen post process,
  35241. */
  35242. private readonly SharpenPostProcessId;
  35243. /**
  35244. * ID of the image processing post process;
  35245. */
  35246. readonly ImageProcessingPostProcessId: string;
  35247. /**
  35248. * ID of the Fast Approximate Anti-Aliasing post process;
  35249. */
  35250. readonly FxaaPostProcessId: string;
  35251. /**
  35252. * ID of the chromatic aberration post process,
  35253. */
  35254. private readonly ChromaticAberrationPostProcessId;
  35255. /**
  35256. * ID of the grain post process
  35257. */
  35258. private readonly GrainPostProcessId;
  35259. /**
  35260. * Sharpen post process which will apply a sharpen convolution to enhance edges
  35261. */
  35262. sharpen: SharpenPostProcess;
  35263. private _sharpenEffect;
  35264. private bloom;
  35265. /**
  35266. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  35267. */
  35268. depthOfField: DepthOfFieldEffect;
  35269. /**
  35270. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  35271. */
  35272. fxaa: FxaaPostProcess;
  35273. /**
  35274. * Image post processing pass used to perform operations such as tone mapping or color grading.
  35275. */
  35276. imageProcessing: ImageProcessingPostProcess;
  35277. /**
  35278. * Chromatic aberration post process which will shift rgb colors in the image
  35279. */
  35280. chromaticAberration: ChromaticAberrationPostProcess;
  35281. private _chromaticAberrationEffect;
  35282. /**
  35283. * Grain post process which add noise to the image
  35284. */
  35285. grain: GrainPostProcess;
  35286. private _grainEffect;
  35287. /**
  35288. * Glow post process which adds a glow to emmisive areas of the image
  35289. */
  35290. private _glowLayer;
  35291. /**
  35292. * Animations which can be used to tweak settings over a period of time
  35293. */
  35294. animations: Animation[];
  35295. private _imageProcessingConfigurationObserver;
  35296. private _sharpenEnabled;
  35297. private _bloomEnabled;
  35298. private _depthOfFieldEnabled;
  35299. private _depthOfFieldBlurLevel;
  35300. private _fxaaEnabled;
  35301. private _imageProcessingEnabled;
  35302. private _defaultPipelineTextureType;
  35303. private _bloomScale;
  35304. private _chromaticAberrationEnabled;
  35305. private _grainEnabled;
  35306. private _buildAllowed;
  35307. /**
  35308. * Enable or disable the sharpen process from the pipeline
  35309. */
  35310. sharpenEnabled: boolean;
  35311. private _resizeObserver;
  35312. private _hardwareScaleLevel;
  35313. private _bloomKernel;
  35314. /**
  35315. * Specifies the size of the bloom blur kernel, relative to the final output size
  35316. */
  35317. bloomKernel: number;
  35318. /**
  35319. * Specifies the weight of the bloom in the final rendering
  35320. */
  35321. private _bloomWeight;
  35322. /**
  35323. * Specifies the luma threshold for the area that will be blurred by the bloom
  35324. */
  35325. private _bloomThreshold;
  35326. private _hdr;
  35327. /**
  35328. * The strength of the bloom.
  35329. */
  35330. bloomWeight: number;
  35331. /**
  35332. * The strength of the bloom.
  35333. */
  35334. bloomThreshold: number;
  35335. /**
  35336. * The scale of the bloom, lower value will provide better performance.
  35337. */
  35338. bloomScale: number;
  35339. /**
  35340. * Enable or disable the bloom from the pipeline
  35341. */
  35342. bloomEnabled: boolean;
  35343. private _rebuildBloom();
  35344. /**
  35345. * If the depth of field is enabled.
  35346. */
  35347. depthOfFieldEnabled: boolean;
  35348. /**
  35349. * Blur level of the depth of field effect. (Higher blur will effect performance)
  35350. */
  35351. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  35352. /**
  35353. * If the anti aliasing is enabled.
  35354. */
  35355. fxaaEnabled: boolean;
  35356. private _samples;
  35357. /**
  35358. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  35359. */
  35360. samples: number;
  35361. /**
  35362. * If image processing is enabled.
  35363. */
  35364. imageProcessingEnabled: boolean;
  35365. /**
  35366. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  35367. */
  35368. glowLayerEnabled: boolean;
  35369. /**
  35370. * Enable or disable the chromaticAberration process from the pipeline
  35371. */
  35372. chromaticAberrationEnabled: boolean;
  35373. /**
  35374. * Enable or disable the grain process from the pipeline
  35375. */
  35376. grainEnabled: boolean;
  35377. /**
  35378. * @constructor
  35379. * @param {string} name - The rendering pipeline name (default: "")
  35380. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  35381. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  35382. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  35383. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  35384. */
  35385. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  35386. /**
  35387. * Force the compilation of the entire pipeline.
  35388. */
  35389. prepare(): void;
  35390. private _hasCleared;
  35391. private _prevPostProcess;
  35392. private _prevPrevPostProcess;
  35393. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  35394. private _buildPipeline();
  35395. private _disposePostProcesses(disposeNonRecreated?);
  35396. /**
  35397. * Dispose of the pipeline and stop all post processes
  35398. */
  35399. dispose(): void;
  35400. /**
  35401. * Serialize the rendering pipeline (Used when exporting)
  35402. * @returns the serialized object
  35403. */
  35404. serialize(): any;
  35405. /**
  35406. * Parse the serialized pipeline
  35407. * @param source Source pipeline.
  35408. * @param scene The scene to load the pipeline to.
  35409. * @param rootUrl The URL of the serialized pipeline.
  35410. * @returns An instantiated pipeline from the serialized object.
  35411. */
  35412. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  35413. }
  35414. }
  35415. declare module BABYLON {
  35416. class LensRenderingPipeline extends PostProcessRenderPipeline {
  35417. /**
  35418. * The chromatic aberration PostProcess id in the pipeline
  35419. */
  35420. LensChromaticAberrationEffect: string;
  35421. /**
  35422. * The highlights enhancing PostProcess id in the pipeline
  35423. */
  35424. HighlightsEnhancingEffect: string;
  35425. /**
  35426. * The depth-of-field PostProcess id in the pipeline
  35427. */
  35428. LensDepthOfFieldEffect: string;
  35429. private _scene;
  35430. private _depthTexture;
  35431. private _grainTexture;
  35432. private _chromaticAberrationPostProcess;
  35433. private _highlightsPostProcess;
  35434. private _depthOfFieldPostProcess;
  35435. private _edgeBlur;
  35436. private _grainAmount;
  35437. private _chromaticAberration;
  35438. private _distortion;
  35439. private _highlightsGain;
  35440. private _highlightsThreshold;
  35441. private _dofDistance;
  35442. private _dofAperture;
  35443. private _dofDarken;
  35444. private _dofPentagon;
  35445. private _blurNoise;
  35446. /**
  35447. * @constructor
  35448. *
  35449. * Effect parameters are as follow:
  35450. * {
  35451. * chromatic_aberration: number; // from 0 to x (1 for realism)
  35452. * edge_blur: number; // from 0 to x (1 for realism)
  35453. * distortion: number; // from 0 to x (1 for realism)
  35454. * grain_amount: number; // from 0 to 1
  35455. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  35456. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  35457. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  35458. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  35459. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  35460. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  35461. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  35462. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  35463. * }
  35464. * Note: if an effect parameter is unset, effect is disabled
  35465. *
  35466. * @param {string} name - The rendering pipeline name
  35467. * @param {object} parameters - An object containing all parameters (see above)
  35468. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35469. * @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)
  35470. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35471. */
  35472. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  35473. setEdgeBlur(amount: number): void;
  35474. disableEdgeBlur(): void;
  35475. setGrainAmount(amount: number): void;
  35476. disableGrain(): void;
  35477. setChromaticAberration(amount: number): void;
  35478. disableChromaticAberration(): void;
  35479. setEdgeDistortion(amount: number): void;
  35480. disableEdgeDistortion(): void;
  35481. setFocusDistance(amount: number): void;
  35482. disableDepthOfField(): void;
  35483. setAperture(amount: number): void;
  35484. setDarkenOutOfFocus(amount: number): void;
  35485. enablePentagonBokeh(): void;
  35486. disablePentagonBokeh(): void;
  35487. enableNoiseBlur(): void;
  35488. disableNoiseBlur(): void;
  35489. setHighlightsGain(amount: number): void;
  35490. setHighlightsThreshold(amount: number): void;
  35491. disableHighlights(): void;
  35492. /**
  35493. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  35494. */
  35495. dispose(disableDepthRender?: boolean): void;
  35496. private _createChromaticAberrationPostProcess(ratio);
  35497. private _createHighlightsPostProcess(ratio);
  35498. private _createDepthOfFieldPostProcess(ratio);
  35499. private _createGrainTexture();
  35500. }
  35501. }
  35502. declare module BABYLON {
  35503. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  35504. /**
  35505. * The PassPostProcess id in the pipeline that contains the original scene color
  35506. */
  35507. SSAOOriginalSceneColorEffect: string;
  35508. /**
  35509. * The SSAO PostProcess id in the pipeline
  35510. */
  35511. SSAORenderEffect: string;
  35512. /**
  35513. * The horizontal blur PostProcess id in the pipeline
  35514. */
  35515. SSAOBlurHRenderEffect: string;
  35516. /**
  35517. * The vertical blur PostProcess id in the pipeline
  35518. */
  35519. SSAOBlurVRenderEffect: string;
  35520. /**
  35521. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35522. */
  35523. SSAOCombineRenderEffect: string;
  35524. /**
  35525. * The output strength of the SSAO post-process. Default value is 1.0.
  35526. */
  35527. totalStrength: number;
  35528. /**
  35529. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  35530. */
  35531. maxZ: number;
  35532. /**
  35533. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  35534. */
  35535. minZAspect: number;
  35536. /**
  35537. * Number of samples used for the SSAO calculations. Default value is 8
  35538. */
  35539. private _samples;
  35540. /**
  35541. * Ratio object used for SSAO ratio and blur ratio
  35542. */
  35543. private _ratio;
  35544. /**
  35545. * Dynamically generated sphere sampler.
  35546. */
  35547. private _sampleSphere;
  35548. /**
  35549. * Blur filter offsets
  35550. */
  35551. private _samplerOffsets;
  35552. samples: number;
  35553. /**
  35554. * Are we using bilateral blur ?
  35555. */
  35556. private _expensiveBlur;
  35557. expensiveBlur: boolean;
  35558. /**
  35559. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  35560. */
  35561. radius: number;
  35562. /**
  35563. * The base color of the SSAO post-process
  35564. * The final result is "base + ssao" between [0, 1]
  35565. */
  35566. base: number;
  35567. /**
  35568. * Support test.
  35569. */
  35570. static readonly IsSupported: boolean;
  35571. private _scene;
  35572. private _depthTexture;
  35573. private _normalTexture;
  35574. private _randomTexture;
  35575. private _originalColorPostProcess;
  35576. private _ssaoPostProcess;
  35577. private _blurHPostProcess;
  35578. private _blurVPostProcess;
  35579. private _ssaoCombinePostProcess;
  35580. private _firstUpdate;
  35581. /**
  35582. * @constructor
  35583. * @param {string} name - The rendering pipeline name
  35584. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35585. * @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 }
  35586. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35587. */
  35588. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35589. /**
  35590. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35591. */
  35592. dispose(disableGeometryBufferRenderer?: boolean): void;
  35593. private _createBlurPostProcess(ssaoRatio, blurRatio);
  35594. _rebuild(): void;
  35595. private _generateHemisphere();
  35596. private _createSSAOPostProcess(ratio);
  35597. private _createSSAOCombinePostProcess(ratio);
  35598. private _createRandomTexture();
  35599. /**
  35600. * Serialize the rendering pipeline (Used when exporting)
  35601. * @returns the serialized object
  35602. */
  35603. serialize(): any;
  35604. /**
  35605. * Parse the serialized pipeline
  35606. * @param source Source pipeline.
  35607. * @param scene The scene to load the pipeline to.
  35608. * @param rootUrl The URL of the serialized pipeline.
  35609. * @returns An instantiated pipeline from the serialized object.
  35610. */
  35611. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  35612. }
  35613. }
  35614. declare module BABYLON {
  35615. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  35616. /**
  35617. * The PassPostProcess id in the pipeline that contains the original scene color
  35618. */
  35619. SSAOOriginalSceneColorEffect: string;
  35620. /**
  35621. * The SSAO PostProcess id in the pipeline
  35622. */
  35623. SSAORenderEffect: string;
  35624. /**
  35625. * The horizontal blur PostProcess id in the pipeline
  35626. */
  35627. SSAOBlurHRenderEffect: string;
  35628. /**
  35629. * The vertical blur PostProcess id in the pipeline
  35630. */
  35631. SSAOBlurVRenderEffect: string;
  35632. /**
  35633. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35634. */
  35635. SSAOCombineRenderEffect: string;
  35636. /**
  35637. * The output strength of the SSAO post-process. Default value is 1.0.
  35638. */
  35639. totalStrength: number;
  35640. /**
  35641. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  35642. */
  35643. radius: number;
  35644. /**
  35645. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  35646. * Must not be equal to fallOff and superior to fallOff.
  35647. * Default value is 0.975
  35648. */
  35649. area: number;
  35650. /**
  35651. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  35652. * Must not be equal to area and inferior to area.
  35653. * Default value is 0.0
  35654. */
  35655. fallOff: number;
  35656. /**
  35657. * The base color of the SSAO post-process
  35658. * The final result is "base + ssao" between [0, 1]
  35659. */
  35660. base: number;
  35661. private _scene;
  35662. private _depthTexture;
  35663. private _randomTexture;
  35664. private _originalColorPostProcess;
  35665. private _ssaoPostProcess;
  35666. private _blurHPostProcess;
  35667. private _blurVPostProcess;
  35668. private _ssaoCombinePostProcess;
  35669. private _firstUpdate;
  35670. /**
  35671. * @constructor
  35672. * @param {string} name - The rendering pipeline name
  35673. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35674. * @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 }
  35675. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35676. */
  35677. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35678. /**
  35679. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35680. */
  35681. dispose(disableDepthRender?: boolean): void;
  35682. private _createBlurPostProcess(ratio);
  35683. _rebuild(): void;
  35684. private _createSSAOPostProcess(ratio);
  35685. private _createSSAOCombinePostProcess(ratio);
  35686. private _createRandomTexture();
  35687. }
  35688. }
  35689. declare module BABYLON {
  35690. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35691. /**
  35692. * Public members
  35693. */
  35694. originalPostProcess: Nullable<PostProcess>;
  35695. downSampleX4PostProcess: Nullable<PostProcess>;
  35696. brightPassPostProcess: Nullable<PostProcess>;
  35697. blurHPostProcesses: PostProcess[];
  35698. blurVPostProcesses: PostProcess[];
  35699. textureAdderPostProcess: Nullable<PostProcess>;
  35700. volumetricLightPostProcess: Nullable<PostProcess>;
  35701. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  35702. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  35703. volumetricLightMergePostProces: Nullable<PostProcess>;
  35704. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  35705. luminancePostProcess: Nullable<PostProcess>;
  35706. luminanceDownSamplePostProcesses: PostProcess[];
  35707. hdrPostProcess: Nullable<PostProcess>;
  35708. textureAdderFinalPostProcess: Nullable<PostProcess>;
  35709. lensFlareFinalPostProcess: Nullable<PostProcess>;
  35710. hdrFinalPostProcess: Nullable<PostProcess>;
  35711. lensFlarePostProcess: Nullable<PostProcess>;
  35712. lensFlareComposePostProcess: Nullable<PostProcess>;
  35713. motionBlurPostProcess: Nullable<PostProcess>;
  35714. depthOfFieldPostProcess: Nullable<PostProcess>;
  35715. brightThreshold: number;
  35716. blurWidth: number;
  35717. horizontalBlur: boolean;
  35718. exposure: number;
  35719. lensTexture: Nullable<Texture>;
  35720. volumetricLightCoefficient: number;
  35721. volumetricLightPower: number;
  35722. volumetricLightBlurScale: number;
  35723. sourceLight: Nullable<SpotLight | DirectionalLight>;
  35724. hdrMinimumLuminance: number;
  35725. hdrDecreaseRate: number;
  35726. hdrIncreaseRate: number;
  35727. lensColorTexture: Nullable<Texture>;
  35728. lensFlareStrength: number;
  35729. lensFlareGhostDispersal: number;
  35730. lensFlareHaloWidth: number;
  35731. lensFlareDistortionStrength: number;
  35732. lensStarTexture: Nullable<Texture>;
  35733. lensFlareDirtTexture: Nullable<Texture>;
  35734. depthOfFieldDistance: number;
  35735. depthOfFieldBlurWidth: number;
  35736. motionStrength: number;
  35737. animations: Animation[];
  35738. /**
  35739. * Private members
  35740. */
  35741. private _scene;
  35742. private _currentDepthOfFieldSource;
  35743. private _basePostProcess;
  35744. private _hdrCurrentLuminance;
  35745. private _floatTextureType;
  35746. private _ratio;
  35747. private _bloomEnabled;
  35748. private _depthOfFieldEnabled;
  35749. private _vlsEnabled;
  35750. private _lensFlareEnabled;
  35751. private _hdrEnabled;
  35752. private _motionBlurEnabled;
  35753. private _motionBlurSamples;
  35754. private _volumetricLightStepsCount;
  35755. BloomEnabled: boolean;
  35756. DepthOfFieldEnabled: boolean;
  35757. LensFlareEnabled: boolean;
  35758. HDREnabled: boolean;
  35759. VLSEnabled: boolean;
  35760. MotionBlurEnabled: boolean;
  35761. volumetricLightStepsCount: number;
  35762. motionBlurSamples: number;
  35763. /**
  35764. * @constructor
  35765. * @param {string} name - The rendering pipeline name
  35766. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35767. * @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)
  35768. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  35769. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35770. */
  35771. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  35772. private _buildPipeline();
  35773. private _createDownSampleX4PostProcess(scene, ratio);
  35774. private _createBrightPassPostProcess(scene, ratio);
  35775. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  35776. private _createTextureAdderPostProcess(scene, ratio);
  35777. private _createVolumetricLightPostProcess(scene, ratio);
  35778. private _createLuminancePostProcesses(scene, textureType);
  35779. private _createHdrPostProcess(scene, ratio);
  35780. private _createLensFlarePostProcess(scene, ratio);
  35781. private _createDepthOfFieldPostProcess(scene, ratio);
  35782. private _createMotionBlurPostProcess(scene, ratio);
  35783. private _getDepthTexture();
  35784. private _disposePostProcesses();
  35785. /**
  35786. * Dispose of the pipeline and stop all post processes
  35787. */
  35788. dispose(): void;
  35789. /**
  35790. * Serialize the rendering pipeline (Used when exporting)
  35791. * @returns the serialized object
  35792. */
  35793. serialize(): any;
  35794. /**
  35795. * Parse the serialized pipeline
  35796. * @param source Source pipeline.
  35797. * @param scene The scene to load the pipeline to.
  35798. * @param rootUrl The URL of the serialized pipeline.
  35799. * @returns An instantiated pipeline from the serialized object.
  35800. */
  35801. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  35802. static LuminanceSteps: number;
  35803. }
  35804. }