babylon.d.ts 1.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /** All of the cameras added to this scene
  62. * @see http://doc.babylonjs.com/babylon101/cameras
  63. */
  64. cameras: Camera[];
  65. /**
  66. * All of the lights added to this scene
  67. * @see http://doc.babylonjs.com/babylon101/lights
  68. */
  69. lights: Light[];
  70. /**
  71. * All of the (abstract) meshes added to this scene
  72. */
  73. meshes: AbstractMesh[];
  74. /**
  75. * The list of skeletons added to the scene
  76. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77. */
  78. skeletons: Skeleton[];
  79. /**
  80. * All of the particle systems added to this scene
  81. * @see http://doc.babylonjs.com/babylon101/particles
  82. */
  83. particleSystems: IParticleSystem[];
  84. /**
  85. * Gets a list of Animations associated with the scene
  86. */
  87. animations: Animation[];
  88. /**
  89. * All of the animation groups added to this scene
  90. * @see http://doc.babylonjs.com/how_to/group
  91. */
  92. animationGroups: AnimationGroup[];
  93. /**
  94. * All of the multi-materials added to this scene
  95. * @see http://doc.babylonjs.com/how_to/multi_materials
  96. */
  97. multiMaterials: MultiMaterial[];
  98. /**
  99. * All of the materials added to this scene
  100. * @see http://doc.babylonjs.com/babylon101/materials
  101. */
  102. materials: Material[];
  103. /**
  104. * The list of morph target managers added to the scene
  105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106. */
  107. morphTargetManagers: MorphTargetManager[];
  108. /**
  109. * The list of geometries used in the scene.
  110. */
  111. geometries: Geometry[];
  112. /**
  113. * All of the tranform nodes added to this scene
  114. * @see http://doc.babylonjs.com/how_to/transformnode
  115. */
  116. transformNodes: TransformNode[];
  117. /**
  118. * ActionManagers available on the scene.
  119. */
  120. actionManagers: ActionManager[];
  121. /**
  122. * Sounds to keep.
  123. */
  124. sounds: Sound[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light Camera).
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. private _ranges;
  369. /**
  370. * Callback raised when the node is ready to be used
  371. */
  372. onReady: (node: Node) => void;
  373. private _isEnabled;
  374. private _isReady;
  375. /** @hidden */
  376. _currentRenderId: number;
  377. private _parentRenderId;
  378. protected _childRenderId: number;
  379. /** @hidden */
  380. _waitingParentId: Nullable<string>;
  381. /** @hidden */
  382. _scene: Scene;
  383. /** @hidden */
  384. _cache: any;
  385. private _parentNode;
  386. private _children;
  387. /**
  388. * Gets a boolean indicating if the node has been disposed
  389. * @returns true if the node was disposed
  390. */
  391. isDisposed(): boolean;
  392. /**
  393. * Gets or sets the parent of the node
  394. */
  395. parent: Nullable<Node>;
  396. private _animationPropertiesOverride;
  397. /**
  398. * Gets or sets the animation properties override
  399. */
  400. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  401. /**
  402. * Gets a string idenfifying the name of the class
  403. * @returns "Node" string
  404. */
  405. getClassName(): string;
  406. /**
  407. * An event triggered when the mesh is disposed
  408. */
  409. onDisposeObservable: Observable<Node>;
  410. private _onDisposeObserver;
  411. /**
  412. * Sets a callback that will be raised when the node will be disposed
  413. */
  414. onDispose: () => void;
  415. /**
  416. * Creates a new Node
  417. * @param {string} name - the name and id to be given to this node
  418. * @param {BABYLON.Scene} the scene this node will be added to
  419. */
  420. constructor(name: string, scene?: Nullable<Scene>);
  421. /**
  422. * Gets the scene of the node
  423. * @returns a {BABYLON.Scene}
  424. */
  425. getScene(): Scene;
  426. /**
  427. * Gets the engine of the node
  428. * @returns a {BABYLON.Engine}
  429. */
  430. getEngine(): Engine;
  431. private _behaviors;
  432. /**
  433. * Attach a behavior to the node
  434. * @see http://doc.babylonjs.com/features/behaviour
  435. * @param behavior defines the behavior to attach
  436. * @returns the current Node
  437. */
  438. addBehavior(behavior: Behavior<Node>): Node;
  439. /**
  440. * Remove an attached behavior
  441. * @see http://doc.babylonjs.com/features/behaviour
  442. * @param behavior defines the behavior to attach
  443. * @returns the current Node
  444. */
  445. removeBehavior(behavior: Behavior<Node>): Node;
  446. /**
  447. * Gets the list of attached behaviors
  448. * @see http://doc.babylonjs.com/features/behaviour
  449. */
  450. readonly behaviors: Behavior<Node>[];
  451. /**
  452. * Gets an attached behavior by name
  453. * @param name defines the name of the behavior to look for
  454. * @see http://doc.babylonjs.com/features/behaviour
  455. * @returns null if behavior was not found else the requested behavior
  456. */
  457. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  458. /**
  459. * Returns the world matrix of the node
  460. * @returns a matrix containing the node's world matrix
  461. */
  462. getWorldMatrix(): Matrix;
  463. /** @hidden */
  464. _getWorldMatrixDeterminant(): number;
  465. /** @hidden */
  466. _initCache(): void;
  467. /** @hidden */
  468. updateCache(force?: boolean): void;
  469. /** @hidden */
  470. _updateCache(ignoreParentClass?: boolean): void;
  471. /** @hidden */
  472. _isSynchronized(): boolean;
  473. /** @hidden */
  474. _markSyncedWithParent(): void;
  475. /** @hidden */
  476. isSynchronizedWithParent(): boolean;
  477. /** @hidden */
  478. isSynchronized(updateCache?: boolean): boolean;
  479. /** @hidden */
  480. hasNewParent(update?: boolean): boolean;
  481. /**
  482. * Is this node ready to be used/rendered
  483. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  484. * @return true if the node is ready
  485. */
  486. isReady(completeCheck?: boolean): boolean;
  487. /**
  488. * Is this node enabled?
  489. * 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
  490. * @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
  491. * @return whether this node (and its parent) is enabled
  492. */
  493. isEnabled(checkAncestors?: boolean): boolean;
  494. /**
  495. * Set the enabled state of this node
  496. * @param value defines the new enabled state
  497. */
  498. setEnabled(value: boolean): void;
  499. /**
  500. * Is this node a descendant of the given node?
  501. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  502. * @param ancestor defines the parent node to inspect
  503. * @returns a boolean indicating if this node is a descendant of the given node
  504. */
  505. isDescendantOf(ancestor: Node): boolean;
  506. /** @hidden */
  507. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  508. /**
  509. * Will return all nodes that have this node as ascendant
  510. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  511. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  512. * @return all children nodes of all types
  513. */
  514. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  515. /**
  516. * Get all child-meshes of this node
  517. * @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
  518. * @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
  519. * @returns an array of {BABYLON.AbstractMesh}
  520. */
  521. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  522. /**
  523. * Get all child-transformNodes of this node
  524. * @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
  525. * @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
  526. * @returns an array of {BABYLON.TransformNode}
  527. */
  528. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  529. /**
  530. * Get all direct children of this node
  531. * @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
  532. * @returns an array of {BABYLON.Node}
  533. */
  534. getChildren(predicate?: (node: Node) => boolean): Node[];
  535. /** @hidden */
  536. _setReady(state: boolean): void;
  537. /**
  538. * Get an animation by name
  539. * @param name defines the name of the animation to look for
  540. * @returns null if not found else the requested animation
  541. */
  542. getAnimationByName(name: string): Nullable<Animation>;
  543. /**
  544. * Creates an animation range for this node
  545. * @param name defines the name of the range
  546. * @param from defines the starting key
  547. * @param to defines the end key
  548. */
  549. createAnimationRange(name: string, from: number, to: number): void;
  550. /**
  551. * Delete a specific animation range
  552. * @param name defines the name of the range to delete
  553. * @param deleteFrames defines if animation frames from the range must be deleted as well
  554. */
  555. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  556. /**
  557. * Get an animation range by name
  558. * @param name defines the name of the animation range to look for
  559. * @returns null if not found else the requested animation range
  560. */
  561. getAnimationRange(name: string): Nullable<AnimationRange>;
  562. /**
  563. * Will start the animation sequence
  564. * @param name defines the range frames for animation sequence
  565. * @param loop defines if the animation should loop (false by default)
  566. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  567. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  568. * @returns the object created for this animation. If range does not exist, it will return null
  569. */
  570. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  571. /**
  572. * Serialize animation ranges into a JSON compatible object
  573. * @returns serialization object
  574. */
  575. serializeAnimationRanges(): any;
  576. /**
  577. * Computes the world matrix of the node
  578. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  579. * @returns the world matrix
  580. */
  581. computeWorldMatrix(force?: boolean): Matrix;
  582. /**
  583. * Releases resources associated with this node.
  584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  586. */
  587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  588. /**
  589. * Parse animation range data from a serialization object and store them into a given node
  590. * @param node defines where to store the animation ranges
  591. * @param parsedNode defines the serialization object to read data from
  592. * @param scene defines the hosting scene
  593. */
  594. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  595. }
  596. }
  597. declare module BABYLON {
  598. /**
  599. * Define an interface for all classes that will hold resources
  600. */
  601. interface IDisposable {
  602. /**
  603. * Releases all held resources
  604. */
  605. dispose(): void;
  606. }
  607. /**
  608. * Interface used to let developers provide their own mesh selection mechanism
  609. */
  610. interface IActiveMeshCandidateProvider {
  611. /**
  612. * Return the list of active meshes
  613. * @param scene defines the current scene
  614. * @returns the list of active meshes
  615. */
  616. getMeshes(scene: Scene): AbstractMesh[];
  617. /**
  618. * Indicates if the meshes have been checked to make sure they are isEnabled()
  619. */
  620. readonly checksIsEnabled: boolean;
  621. }
  622. /**
  623. * This class is used by the onRenderingGroupObservable
  624. */
  625. class RenderingGroupInfo {
  626. /**
  627. * The Scene that being rendered
  628. */
  629. scene: Scene;
  630. /**
  631. * The camera currently used for the rendering pass
  632. */
  633. camera: Nullable<Camera>;
  634. /**
  635. * The ID of the renderingGroup being processed
  636. */
  637. renderingGroupId: number;
  638. }
  639. /**
  640. * Represents a scene to be rendered by the engine.
  641. * @see http://doc.babylonjs.com/features/scene
  642. */
  643. class Scene extends AbstractScene implements IAnimatable {
  644. private static _FOGMODE_NONE;
  645. private static _FOGMODE_EXP;
  646. private static _FOGMODE_EXP2;
  647. private static _FOGMODE_LINEAR;
  648. private static _uniqueIdCounter;
  649. /**
  650. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  652. */
  653. static MinDeltaTime: number;
  654. /**
  655. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  656. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  657. */
  658. static MaxDeltaTime: number;
  659. /** The fog is deactivated */
  660. static readonly FOGMODE_NONE: number;
  661. /** The fog density is following an exponential function */
  662. static readonly FOGMODE_EXP: number;
  663. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  664. static readonly FOGMODE_EXP2: number;
  665. /** The fog density is following a linear function. */
  666. static readonly FOGMODE_LINEAR: number;
  667. /**
  668. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  669. */
  670. autoClear: boolean;
  671. /**
  672. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  673. */
  674. autoClearDepthAndStencil: boolean;
  675. /**
  676. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  677. */
  678. clearColor: Color4;
  679. /**
  680. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  681. */
  682. ambientColor: Color3;
  683. /** @hidden */
  684. _environmentBRDFTexture: BaseTexture;
  685. /** @hidden */
  686. protected _environmentTexture: BaseTexture;
  687. /**
  688. * Texture used in all pbr material as the reflection texture.
  689. * As in the majority of the scene they are the same (exception for multi room and so on),
  690. * this is easier to reference from here than from all the materials.
  691. */
  692. /**
  693. * Texture used in all pbr material as the reflection texture.
  694. * As in the majority of the scene they are the same (exception for multi room and so on),
  695. * this is easier to set here than in all the materials.
  696. */
  697. environmentTexture: BaseTexture;
  698. /** @hidden */
  699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  700. /**
  701. * Default image processing configuration used either in the rendering
  702. * Forward main pass or through the imageProcessingPostProcess if present.
  703. * As in the majority of the scene they are the same (exception for multi camera),
  704. * this is easier to reference from here than from all the materials and post process.
  705. *
  706. * No setter as we it is a shared configuration, you can set the values instead.
  707. */
  708. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  709. private _forceWireframe;
  710. /**
  711. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  712. */
  713. forceWireframe: boolean;
  714. private _forcePointsCloud;
  715. /**
  716. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  717. */
  718. forcePointsCloud: boolean;
  719. /**
  720. * Gets or sets the active clipplane
  721. */
  722. clipPlane: Nullable<Plane>;
  723. /**
  724. * Gets or sets a boolean indicating if animations are enabled
  725. */
  726. animationsEnabled: boolean;
  727. private _animationPropertiesOverride;
  728. /**
  729. * Gets or sets the animation properties override
  730. */
  731. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  732. /**
  733. * Gets or sets a boolean indicating if a constant deltatime has to be used
  734. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  735. */
  736. useConstantAnimationDeltaTime: boolean;
  737. /**
  738. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  739. * Please note that it requires to run a ray cast through the scene on every frame
  740. */
  741. constantlyUpdateMeshUnderPointer: boolean;
  742. /**
  743. * Defines the HTML cursor to use when hovering over interactive elements
  744. */
  745. hoverCursor: string;
  746. /**
  747. * Defines the HTML default cursor to use (empty by default)
  748. */
  749. defaultCursor: string;
  750. /**
  751. * This is used to call preventDefault() on pointer down
  752. * in order to block unwanted artifacts like system double clicks
  753. */
  754. preventDefaultOnPointerDown: boolean;
  755. /**
  756. * Gets or sets user defined metadata
  757. */
  758. metadata: any;
  759. /**
  760. * Gets the name of the plugin used to load this scene (null by default)
  761. */
  762. loadingPluginName: string;
  763. /**
  764. * Use this array to add regular expressions used to disable offline support for specific urls
  765. */
  766. disableOfflineSupportExceptionRules: RegExp[];
  767. private _spritePredicate;
  768. /**
  769. * An event triggered when the scene is disposed.
  770. */
  771. onDisposeObservable: Observable<Scene>;
  772. private _onDisposeObserver;
  773. /** Sets a function to be executed when this scene is disposed. */
  774. onDispose: () => void;
  775. /**
  776. * An event triggered before rendering the scene (right after animations and physics)
  777. */
  778. onBeforeRenderObservable: Observable<Scene>;
  779. private _onBeforeRenderObserver;
  780. /** Sets a function to be executed before rendering this scene */
  781. beforeRender: Nullable<() => void>;
  782. /**
  783. * An event triggered after rendering the scene
  784. */
  785. onAfterRenderObservable: Observable<Scene>;
  786. private _onAfterRenderObserver;
  787. /** Sets a function to be executed after rendering this scene */
  788. afterRender: Nullable<() => void>;
  789. /**
  790. * An event triggered before animating the scene
  791. */
  792. onBeforeAnimationsObservable: Observable<Scene>;
  793. /**
  794. * An event triggered after animations processing
  795. */
  796. onAfterAnimationsObservable: Observable<Scene>;
  797. /**
  798. * An event triggered before draw calls are ready to be sent
  799. */
  800. onBeforeDrawPhaseObservable: Observable<Scene>;
  801. /**
  802. * An event triggered after draw calls have been sent
  803. */
  804. onAfterDrawPhaseObservable: Observable<Scene>;
  805. /**
  806. * An event triggered when physic simulation is about to be run
  807. */
  808. onBeforePhysicsObservable: Observable<Scene>;
  809. /**
  810. * An event triggered when physic simulation has been done
  811. */
  812. onAfterPhysicsObservable: Observable<Scene>;
  813. /**
  814. * An event triggered when the scene is ready
  815. */
  816. onReadyObservable: Observable<Scene>;
  817. /**
  818. * An event triggered before rendering a camera
  819. */
  820. onBeforeCameraRenderObservable: Observable<Camera>;
  821. private _onBeforeCameraRenderObserver;
  822. /** Sets a function to be executed before rendering a camera*/
  823. beforeCameraRender: () => void;
  824. /**
  825. * An event triggered after rendering a camera
  826. */
  827. onAfterCameraRenderObservable: Observable<Camera>;
  828. private _onAfterCameraRenderObserver;
  829. /** Sets a function to be executed after rendering a camera*/
  830. afterCameraRender: () => void;
  831. /**
  832. * An event triggered when active meshes evaluation is about to start
  833. */
  834. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  835. /**
  836. * An event triggered when active meshes evaluation is done
  837. */
  838. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  839. /**
  840. * An event triggered when particles rendering is about to start
  841. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  842. */
  843. onBeforeParticlesRenderingObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when particles rendering is done
  846. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  847. */
  848. onAfterParticlesRenderingObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when sprites rendering is about to start
  851. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  852. */
  853. onBeforeSpritesRenderingObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when sprites rendering is done
  856. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  857. */
  858. onAfterSpritesRenderingObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  861. */
  862. onDataLoadedObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when a camera is created
  865. */
  866. onNewCameraAddedObservable: Observable<Camera>;
  867. /**
  868. * An event triggered when a camera is removed
  869. */
  870. onCameraRemovedObservable: Observable<Camera>;
  871. /**
  872. * An event triggered when a light is created
  873. */
  874. onNewLightAddedObservable: Observable<Light>;
  875. /**
  876. * An event triggered when a light is removed
  877. */
  878. onLightRemovedObservable: Observable<Light>;
  879. /**
  880. * An event triggered when a geometry is created
  881. */
  882. onNewGeometryAddedObservable: Observable<Geometry>;
  883. /**
  884. * An event triggered when a geometry is removed
  885. */
  886. onGeometryRemovedObservable: Observable<Geometry>;
  887. /**
  888. * An event triggered when a transform node is created
  889. */
  890. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  891. /**
  892. * An event triggered when a transform node is removed
  893. */
  894. onTransformNodeRemovedObservable: Observable<TransformNode>;
  895. /**
  896. * An event triggered when a mesh is created
  897. */
  898. onNewMeshAddedObservable: Observable<AbstractMesh>;
  899. /**
  900. * An event triggered when a mesh is removed
  901. */
  902. onMeshRemovedObservable: Observable<AbstractMesh>;
  903. /**
  904. * An event triggered when render targets are about to be rendered
  905. * Can happen multiple times per frame.
  906. */
  907. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  908. /**
  909. * An event triggered when render targets were rendered.
  910. * Can happen multiple times per frame.
  911. */
  912. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  913. /**
  914. * An event triggered before calculating deterministic simulation step
  915. */
  916. onBeforeStepObservable: Observable<Scene>;
  917. /**
  918. * An event triggered after calculating deterministic simulation step
  919. */
  920. onAfterStepObservable: Observable<Scene>;
  921. /**
  922. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  923. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  924. * 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)
  925. */
  926. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  927. /**
  928. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  929. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  930. * 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)
  931. */
  932. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  933. private _registeredForLateAnimationBindings;
  934. /**
  935. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  936. */
  937. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  938. /**
  939. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  940. */
  941. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  942. /**
  943. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  944. */
  945. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  946. private _onPointerMove;
  947. private _onPointerDown;
  948. private _onPointerUp;
  949. /** Deprecated. Use onPointerObservable instead */
  950. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  951. /** Deprecated. Use onPointerObservable instead */
  952. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  953. /** Deprecated. Use onPointerObservable instead */
  954. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  955. /** Deprecated. Use onPointerObservable instead */
  956. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  957. /**
  958. * 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).
  959. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  960. */
  961. onPrePointerObservable: Observable<PointerInfoPre>;
  962. /**
  963. * Observable event triggered each time an input event is received from the rendering canvas
  964. */
  965. onPointerObservable: Observable<PointerInfo>;
  966. /**
  967. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  968. */
  969. readonly unTranslatedPointer: Vector2;
  970. /** The distance in pixel that you have to move to prevent some events */
  971. static DragMovementThreshold: number;
  972. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  973. static LongPressDelay: number;
  974. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  975. static DoubleClickDelay: number;
  976. /** If you need to check double click without raising a single click at first click, enable this flag */
  977. static ExclusiveDoubleClickMode: boolean;
  978. private _initClickEvent;
  979. private _initActionManager;
  980. private _delayedSimpleClick;
  981. private _delayedSimpleClickTimeout;
  982. private _previousDelayedSimpleClickTimeout;
  983. private _meshPickProceed;
  984. private _previousButtonPressed;
  985. private _currentPickResult;
  986. private _previousPickResult;
  987. private _totalPointersPressed;
  988. private _doubleClickOccured;
  989. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  990. cameraToUseForPointers: Nullable<Camera>;
  991. private _pointerX;
  992. private _pointerY;
  993. private _unTranslatedPointerX;
  994. private _unTranslatedPointerY;
  995. private _startingPointerPosition;
  996. private _previousStartingPointerPosition;
  997. private _startingPointerTime;
  998. private _previousStartingPointerTime;
  999. private _pointerCaptures;
  1000. private _timeAccumulator;
  1001. private _currentStepId;
  1002. private _currentInternalStep;
  1003. /** @hidden */
  1004. _mirroredCameraPosition: Nullable<Vector3>;
  1005. /**
  1006. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1007. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1008. */
  1009. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1010. /**
  1011. * Observable event triggered each time an keyboard event is received from the hosting window
  1012. */
  1013. onKeyboardObservable: Observable<KeyboardInfo>;
  1014. private _onKeyDown;
  1015. private _onKeyUp;
  1016. private _onCanvasFocusObserver;
  1017. private _onCanvasBlurObserver;
  1018. private _useRightHandedSystem;
  1019. /**
  1020. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1021. */
  1022. useRightHandedSystem: boolean;
  1023. /**
  1024. * Sets the step Id used by deterministic lock step
  1025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1026. * @param newStepId defines the step Id
  1027. */
  1028. setStepId(newStepId: number): void;
  1029. /**
  1030. * Gets the step Id used by deterministic lock step
  1031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1032. * @returns the step Id
  1033. */
  1034. getStepId(): number;
  1035. /**
  1036. * Gets the internal step used by deterministic lock step
  1037. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1038. * @returns the internal step
  1039. */
  1040. getInternalStep(): number;
  1041. private _fogEnabled;
  1042. /**
  1043. * Gets or sets a boolean indicating if fog is enabled on this scene
  1044. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1045. */
  1046. fogEnabled: boolean;
  1047. private _fogMode;
  1048. /**
  1049. * Gets or sets the fog mode to use
  1050. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1051. */
  1052. fogMode: number;
  1053. /**
  1054. * Gets or sets the fog color to use
  1055. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1056. */
  1057. fogColor: Color3;
  1058. /**
  1059. * Gets or sets the fog density to use
  1060. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1061. */
  1062. fogDensity: number;
  1063. /**
  1064. * Gets or sets the fog start distance to use
  1065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1066. */
  1067. fogStart: number;
  1068. /**
  1069. * Gets or sets the fog end distance to use
  1070. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1071. */
  1072. fogEnd: number;
  1073. private _shadowsEnabled;
  1074. /**
  1075. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1076. */
  1077. shadowsEnabled: boolean;
  1078. private _lightsEnabled;
  1079. /**
  1080. * Gets or sets a boolean indicating if lights are enabled on this scene
  1081. */
  1082. lightsEnabled: boolean;
  1083. /** All of the active cameras added to this scene. */
  1084. activeCameras: Camera[];
  1085. /** The current active camera */
  1086. activeCamera: Nullable<Camera>;
  1087. private _defaultMaterial;
  1088. /** The default material used on meshes when no material is affected */
  1089. /** The default material used on meshes when no material is affected */
  1090. defaultMaterial: Material;
  1091. private _texturesEnabled;
  1092. /**
  1093. * Gets or sets a boolean indicating if textures are enabled on this scene
  1094. */
  1095. texturesEnabled: boolean;
  1096. /**
  1097. * Gets or sets a boolean indicating if particles are enabled on this scene
  1098. */
  1099. particlesEnabled: boolean;
  1100. /**
  1101. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1102. */
  1103. spritesEnabled: boolean;
  1104. /**
  1105. * All of the sprite managers added to this scene
  1106. * @see http://doc.babylonjs.com/babylon101/sprites
  1107. */
  1108. spriteManagers: SpriteManager[];
  1109. private _skeletonsEnabled;
  1110. /**
  1111. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1112. */
  1113. skeletonsEnabled: boolean;
  1114. /**
  1115. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1116. */
  1117. lensFlaresEnabled: boolean;
  1118. /**
  1119. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1121. */
  1122. collisionsEnabled: boolean;
  1123. private _workerCollisions;
  1124. /** @hidden */
  1125. collisionCoordinator: ICollisionCoordinator;
  1126. /**
  1127. * Defines the gravity applied to this scene (used only for collisions)
  1128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1129. */
  1130. gravity: Vector3;
  1131. /**
  1132. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1133. */
  1134. postProcessesEnabled: boolean;
  1135. /**
  1136. * The list of postprocesses added to the scene
  1137. */
  1138. postProcesses: PostProcess[];
  1139. /**
  1140. * Gets the current postprocess manager
  1141. */
  1142. postProcessManager: PostProcessManager;
  1143. private _postProcessRenderPipelineManager;
  1144. /**
  1145. * Gets the postprocess render pipeline manager
  1146. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1147. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1148. */
  1149. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1150. /**
  1151. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1152. */
  1153. renderTargetsEnabled: boolean;
  1154. /**
  1155. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1156. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1157. */
  1158. dumpNextRenderTargets: boolean;
  1159. /**
  1160. * The list of user defined render targets added to the scene
  1161. */
  1162. customRenderTargets: RenderTargetTexture[];
  1163. /**
  1164. * Defines if texture loading must be delayed
  1165. * If true, textures will only be loaded when they need to be rendered
  1166. */
  1167. useDelayedTextureLoading: boolean;
  1168. /**
  1169. * Gets the list of meshes imported to the scene through SceneLoader
  1170. */
  1171. importedMeshesFiles: String[];
  1172. /**
  1173. * Gets or sets a boolean indicating if probes are enabled on this scene
  1174. */
  1175. probesEnabled: boolean;
  1176. /**
  1177. * The list of reflection probes added to the scene
  1178. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1179. */
  1180. reflectionProbes: ReflectionProbe[];
  1181. /**
  1182. * @hidden
  1183. */
  1184. database: Database;
  1185. /**
  1186. * Gets or sets the action manager associated with the scene
  1187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1188. */
  1189. actionManager: ActionManager;
  1190. private _meshesForIntersections;
  1191. /**
  1192. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1193. */
  1194. proceduralTexturesEnabled: boolean;
  1195. /**
  1196. * The list of procedural textures added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1198. */
  1199. proceduralTextures: ProceduralTexture[];
  1200. private _mainSoundTrack;
  1201. /**
  1202. * The list of sound tracks added to the scene
  1203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1204. */
  1205. soundTracks: SoundTrack[];
  1206. private _audioEnabled;
  1207. private _headphone;
  1208. /**
  1209. * Gets the main soundtrack associated with the scene
  1210. */
  1211. readonly mainSoundTrack: SoundTrack;
  1212. /**
  1213. * Gets or sets the VRExperienceHelper attached to the scene
  1214. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1215. * @ignorenaming
  1216. */
  1217. VRHelper: VRExperienceHelper;
  1218. /**
  1219. * Gets or sets the simplification queue attached to the scene
  1220. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1221. */
  1222. simplificationQueue: SimplificationQueue;
  1223. private _engine;
  1224. private _totalVertices;
  1225. /** @hidden */
  1226. _activeIndices: PerfCounter;
  1227. /** @hidden */
  1228. _activeParticles: PerfCounter;
  1229. /** @hidden */
  1230. _activeBones: PerfCounter;
  1231. private _animationRatio;
  1232. private _animationTimeLast;
  1233. private _animationTime;
  1234. /**
  1235. * Gets or sets a general scale for animation speed
  1236. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1237. */
  1238. animationTimeScale: number;
  1239. /** @hidden */
  1240. _cachedMaterial: Nullable<Material>;
  1241. /** @hidden */
  1242. _cachedEffect: Nullable<Effect>;
  1243. /** @hidden */
  1244. _cachedVisibility: Nullable<number>;
  1245. private _renderId;
  1246. private _executeWhenReadyTimeoutId;
  1247. private _intermediateRendering;
  1248. private _viewUpdateFlag;
  1249. private _projectionUpdateFlag;
  1250. private _alternateViewUpdateFlag;
  1251. private _alternateProjectionUpdateFlag;
  1252. /** @hidden */
  1253. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1254. private _activeRequests;
  1255. private _pendingData;
  1256. private _isDisposed;
  1257. /**
  1258. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1259. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1260. */
  1261. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1262. private _activeMeshes;
  1263. private _processedMaterials;
  1264. private _renderTargets;
  1265. /** @hidden */
  1266. _activeParticleSystems: SmartArray<IParticleSystem>;
  1267. private _activeSkeletons;
  1268. private _softwareSkinnedMeshes;
  1269. private _renderingManager;
  1270. private _physicsEngine;
  1271. /** @hidden */
  1272. _activeAnimatables: Animatable[];
  1273. private _transformMatrix;
  1274. private _sceneUbo;
  1275. private _alternateSceneUbo;
  1276. private _pickWithRayInverseMatrix;
  1277. private _outlineRenderer;
  1278. private _viewMatrix;
  1279. private _projectionMatrix;
  1280. private _alternateViewMatrix;
  1281. private _alternateProjectionMatrix;
  1282. private _alternateTransformMatrix;
  1283. private _useAlternateCameraConfiguration;
  1284. private _alternateRendering;
  1285. /** @hidden */
  1286. _forcedViewPosition: Nullable<Vector3>;
  1287. /** @hidden */
  1288. readonly _isAlternateRenderingEnabled: boolean;
  1289. private _frustumPlanes;
  1290. /**
  1291. * Gets the list of frustum planes (built from the active camera)
  1292. */
  1293. readonly frustumPlanes: Plane[];
  1294. /**
  1295. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1296. * This is useful if there are more lights that the maximum simulteanous authorized
  1297. */
  1298. requireLightSorting: boolean;
  1299. private _selectionOctree;
  1300. private _pointerOverMesh;
  1301. private _pointerOverSprite;
  1302. private _debugLayer;
  1303. private _depthRenderer;
  1304. private _geometryBufferRenderer;
  1305. /**
  1306. * Gets the current geometry buffer associated to the scene.
  1307. */
  1308. /**
  1309. * Sets the current geometry buffer for the scene.
  1310. */
  1311. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1312. private _pickedDownMesh;
  1313. private _pickedUpMesh;
  1314. private _pickedDownSprite;
  1315. private _externalData;
  1316. private _uid;
  1317. /**
  1318. * Backing store of defined scene components.
  1319. */
  1320. _components: ISceneComponent[];
  1321. /**
  1322. * Backing store of defined scene components.
  1323. */
  1324. _serializableComponents: ISceneSerializableComponent[];
  1325. /**
  1326. * List of components to register on the next registration step.
  1327. */
  1328. private _transientComponents;
  1329. /**
  1330. * Registers the transient components if needed.
  1331. */
  1332. private _registerTransientComponents;
  1333. /**
  1334. * Add a component to the scene.
  1335. * Note that the ccomponent could be registered on th next frame if this is called after
  1336. * the register component stage.
  1337. * @param component Defines the component to add to the scene
  1338. */
  1339. _addComponent(component: ISceneComponent): void;
  1340. /**
  1341. * Gets a component from the scene.
  1342. * @param name defines the name of the component to retrieve
  1343. * @returns the component or null if not present
  1344. */
  1345. _getComponent(name: string): Nullable<ISceneComponent>;
  1346. /**
  1347. * Defines the actions happening before camera updates.
  1348. */
  1349. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1350. /**
  1351. * Defines the actions happening during the per mesh ready checks.
  1352. */
  1353. _isReadyForMeshStage: Stage<MeshStageAction>;
  1354. /**
  1355. * Defines the actions happening before evaluate active mesh checks.
  1356. */
  1357. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1358. /**
  1359. * Defines the actions happening during the evaluate sub mesh checks.
  1360. */
  1361. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1362. /**
  1363. * Defines the actions happening during the active mesh stage.
  1364. */
  1365. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1366. /**
  1367. * Defines the actions happening during the per camera render target step.
  1368. */
  1369. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1370. /**
  1371. * Defines the actions happening just before the active camera is drawing.
  1372. */
  1373. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1374. /**
  1375. * Defines the actions happening just before a rendering group is drawing.
  1376. */
  1377. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1378. /**
  1379. * Defines the actions happening just after a rendering group has been drawn.
  1380. */
  1381. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1382. /**
  1383. * Defines the actions happening just after the active camera has been drawn.
  1384. */
  1385. _afterCameraDrawStage: Stage<CameraStageAction>;
  1386. /**
  1387. * Creates a new Scene
  1388. * @param engine defines the engine to use to render this scene
  1389. */
  1390. constructor(engine: Engine);
  1391. /**
  1392. * Gets the debug layer (aka Inspector) associated with the scene
  1393. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1394. */
  1395. readonly debugLayer: DebugLayer;
  1396. /**
  1397. * Gets a boolean indicating if collisions are processed on a web worker
  1398. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1399. */
  1400. workerCollisions: boolean;
  1401. /**
  1402. * Gets the octree used to boost mesh selection (picking)
  1403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1404. */
  1405. readonly selectionOctree: Octree<AbstractMesh>;
  1406. /**
  1407. * Gets the mesh that is currently under the pointer
  1408. */
  1409. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1410. /**
  1411. * Gets the current on-screen X position of the pointer
  1412. */
  1413. readonly pointerX: number;
  1414. /**
  1415. * Gets the current on-screen Y position of the pointer
  1416. */
  1417. readonly pointerY: number;
  1418. /**
  1419. * Gets the cached material (ie. the latest rendered one)
  1420. * @returns the cached material
  1421. */
  1422. getCachedMaterial(): Nullable<Material>;
  1423. /**
  1424. * Gets the cached effect (ie. the latest rendered one)
  1425. * @returns the cached effect
  1426. */
  1427. getCachedEffect(): Nullable<Effect>;
  1428. /**
  1429. * Gets the cached visibility state (ie. the latest rendered one)
  1430. * @returns the cached visibility state
  1431. */
  1432. getCachedVisibility(): Nullable<number>;
  1433. /**
  1434. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1435. * @param material defines the current material
  1436. * @param effect defines the current effect
  1437. * @param visibility defines the current visibility state
  1438. * @returns true if one parameter is not cached
  1439. */
  1440. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1441. /**
  1442. * Gets the outline renderer associated with the scene
  1443. * @returns a OutlineRenderer
  1444. */
  1445. getOutlineRenderer(): OutlineRenderer;
  1446. /**
  1447. * Gets the engine associated with the scene
  1448. * @returns an Engine
  1449. */
  1450. getEngine(): Engine;
  1451. /**
  1452. * Gets the total number of vertices rendered per frame
  1453. * @returns the total number of vertices rendered per frame
  1454. */
  1455. getTotalVertices(): number;
  1456. /**
  1457. * Gets the performance counter for total vertices
  1458. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1459. */
  1460. readonly totalVerticesPerfCounter: PerfCounter;
  1461. /**
  1462. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1463. * @returns the total number of active indices rendered per frame
  1464. */
  1465. getActiveIndices(): number;
  1466. /**
  1467. * Gets the performance counter for active indices
  1468. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1469. */
  1470. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1471. /**
  1472. * Gets the total number of active particles rendered per frame
  1473. * @returns the total number of active particles rendered per frame
  1474. */
  1475. getActiveParticles(): number;
  1476. /**
  1477. * Gets the performance counter for active particles
  1478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1479. */
  1480. readonly activeParticlesPerfCounter: PerfCounter;
  1481. /**
  1482. * Gets the total number of active bones rendered per frame
  1483. * @returns the total number of active bones rendered per frame
  1484. */
  1485. getActiveBones(): number;
  1486. /**
  1487. * Gets the performance counter for active bones
  1488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1489. */
  1490. readonly activeBonesPerfCounter: PerfCounter;
  1491. /** @hidden */
  1492. getInterFramePerfCounter(): number;
  1493. /** @hidden */
  1494. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1495. /** @hidden */
  1496. getLastFrameDuration(): number;
  1497. /** @hidden */
  1498. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1499. /** @hidden */
  1500. getEvaluateActiveMeshesDuration(): number;
  1501. /** @hidden */
  1502. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1503. /**
  1504. * Gets the array of active meshes
  1505. * @returns an array of AbstractMesh
  1506. */
  1507. getActiveMeshes(): SmartArray<AbstractMesh>;
  1508. /** @hidden */
  1509. getRenderTargetsDuration(): number;
  1510. /** @hidden */
  1511. getRenderDuration(): number;
  1512. /** @hidden */
  1513. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1514. /** @hidden */
  1515. getParticlesDuration(): number;
  1516. /** @hidden */
  1517. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1518. /** @hidden */
  1519. getSpritesDuration(): number;
  1520. /** @hidden */
  1521. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1522. /**
  1523. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1524. * @returns a number
  1525. */
  1526. getAnimationRatio(): number;
  1527. /**
  1528. * Gets an unique Id for the current frame
  1529. * @returns a number
  1530. */
  1531. getRenderId(): number;
  1532. /** Call this function if you want to manually increment the render Id*/
  1533. incrementRenderId(): void;
  1534. private _updatePointerPosition;
  1535. private _createUbo;
  1536. private _createAlternateUbo;
  1537. private _pickSpriteButKeepRay;
  1538. private _setRayOnPointerInfo;
  1539. /**
  1540. * Use this method to simulate a pointer move on a mesh
  1541. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1542. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1543. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1544. * @returns the current scene
  1545. */
  1546. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1547. private _processPointerMove;
  1548. private _checkPrePointerObservable;
  1549. /**
  1550. * Use this method to simulate a pointer down on a mesh
  1551. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1552. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1553. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1554. * @returns the current scene
  1555. */
  1556. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1557. private _processPointerDown;
  1558. /**
  1559. * Use this method to simulate a pointer up on a mesh
  1560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1563. * @returns the current scene
  1564. */
  1565. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1566. private _processPointerUp;
  1567. /**
  1568. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1569. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1570. * @returns true if the pointer was captured
  1571. */
  1572. isPointerCaptured(pointerId?: number): boolean;
  1573. /**
  1574. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1575. * @param attachUp defines if you want to attach events to pointerup
  1576. * @param attachDown defines if you want to attach events to pointerdown
  1577. * @param attachMove defines if you want to attach events to pointermove
  1578. */
  1579. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1580. /** Detaches all event handlers*/
  1581. detachControl(): void;
  1582. /**
  1583. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1584. * Delay loaded resources are not taking in account
  1585. * @return true if all required resources are ready
  1586. */
  1587. isReady(): boolean;
  1588. /** Resets all cached information relative to material (including effect and visibility) */
  1589. resetCachedMaterial(): void;
  1590. /**
  1591. * Registers a function to be called before every frame render
  1592. * @param func defines the function to register
  1593. */
  1594. registerBeforeRender(func: () => void): void;
  1595. /**
  1596. * Unregisters a function called before every frame render
  1597. * @param func defines the function to unregister
  1598. */
  1599. unregisterBeforeRender(func: () => void): void;
  1600. /**
  1601. * Registers a function to be called after every frame render
  1602. * @param func defines the function to register
  1603. */
  1604. registerAfterRender(func: () => void): void;
  1605. /**
  1606. * Unregisters a function called after every frame render
  1607. * @param func defines the function to unregister
  1608. */
  1609. unregisterAfterRender(func: () => void): void;
  1610. private _executeOnceBeforeRender;
  1611. /**
  1612. * The provided function will run before render once and will be disposed afterwards.
  1613. * A timeout delay can be provided so that the function will be executed in N ms.
  1614. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1615. * @param func The function to be executed.
  1616. * @param timeout optional delay in ms
  1617. */
  1618. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1619. /** @hidden */
  1620. _addPendingData(data: any): void;
  1621. /** @hidden */
  1622. _removePendingData(data: any): void;
  1623. /**
  1624. * Returns the number of items waiting to be loaded
  1625. * @returns the number of items waiting to be loaded
  1626. */
  1627. getWaitingItemsCount(): number;
  1628. /**
  1629. * Returns a boolean indicating if the scene is still loading data
  1630. */
  1631. readonly isLoading: boolean;
  1632. /**
  1633. * Registers a function to be executed when the scene is ready
  1634. * @param {Function} func - the function to be executed
  1635. */
  1636. executeWhenReady(func: () => void): void;
  1637. /**
  1638. * Returns a promise that resolves when the scene is ready
  1639. * @returns A promise that resolves when the scene is ready
  1640. */
  1641. whenReadyAsync(): Promise<void>;
  1642. /** @hidden */
  1643. _checkIsReady(): void;
  1644. /**
  1645. * Will start the animation sequence of a given target
  1646. * @param target defines the target
  1647. * @param from defines from which frame should animation start
  1648. * @param to defines until which frame should animation run.
  1649. * @param weight defines the weight to apply to the animation (1.0 by default)
  1650. * @param loop defines if the animation loops
  1651. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1652. * @param onAnimationEnd defines the function to be executed when the animation ends
  1653. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1654. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1655. * @returns the animatable object created for this animation
  1656. */
  1657. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1658. /**
  1659. * Will start the animation sequence of a given target
  1660. * @param target defines the target
  1661. * @param from defines from which frame should animation start
  1662. * @param to defines until which frame should animation run.
  1663. * @param loop defines if the animation loops
  1664. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1665. * @param onAnimationEnd defines the function to be executed when the animation ends
  1666. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1667. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1668. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1669. * @returns the animatable object created for this animation
  1670. */
  1671. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1672. /**
  1673. * Begin a new animation on a given node
  1674. * @param target defines the target where the animation will take place
  1675. * @param animations defines the list of animations to start
  1676. * @param from defines the initial value
  1677. * @param to defines the final value
  1678. * @param loop defines if you want animation to loop (off by default)
  1679. * @param speedRatio defines the speed ratio to apply to all animations
  1680. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1681. * @returns the list of created animatables
  1682. */
  1683. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1684. /**
  1685. * Begin a new animation on a given node and its hierarchy
  1686. * @param target defines the root node where the animation will take place
  1687. * @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.
  1688. * @param animations defines the list of animations to start
  1689. * @param from defines the initial value
  1690. * @param to defines the final value
  1691. * @param loop defines if you want animation to loop (off by default)
  1692. * @param speedRatio defines the speed ratio to apply to all animations
  1693. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1694. * @returns the list of animatables created for all nodes
  1695. */
  1696. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1697. /**
  1698. * Gets the animatable associated with a specific target
  1699. * @param target defines the target of the animatable
  1700. * @returns the required animatable if found
  1701. */
  1702. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1703. /**
  1704. * Gets all animatables associated with a given target
  1705. * @param target defines the target to look animatables for
  1706. * @returns an array of Animatables
  1707. */
  1708. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1709. /**
  1710. * Gets all animatable attached to the scene
  1711. */
  1712. readonly animatables: Animatable[];
  1713. /**
  1714. * Will stop the animation of the given target
  1715. * @param target - the target
  1716. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1717. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1718. */
  1719. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1720. /**
  1721. * Stops and removes all animations that have been applied to the scene
  1722. */
  1723. stopAllAnimations(): void;
  1724. private _animate;
  1725. /** @hidden */
  1726. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1727. private _processLateAnimationBindingsForMatrices;
  1728. private _processLateAnimationBindingsForQuaternions;
  1729. private _processLateAnimationBindings;
  1730. /** @hidden */
  1731. _switchToAlternateCameraConfiguration(active: boolean): void;
  1732. /**
  1733. * Gets the current view matrix
  1734. * @returns a Matrix
  1735. */
  1736. getViewMatrix(): Matrix;
  1737. /**
  1738. * Gets the current projection matrix
  1739. * @returns a Matrix
  1740. */
  1741. getProjectionMatrix(): Matrix;
  1742. /**
  1743. * Gets the current transform matrix
  1744. * @returns a Matrix made of View * Projection
  1745. */
  1746. getTransformMatrix(): Matrix;
  1747. /**
  1748. * Sets the current transform matrix
  1749. * @param view defines the View matrix to use
  1750. * @param projection defines the Projection matrix to use
  1751. */
  1752. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1753. /** @hidden */
  1754. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1755. /**
  1756. * Gets the uniform buffer used to store scene data
  1757. * @returns a UniformBuffer
  1758. */
  1759. getSceneUniformBuffer(): UniformBuffer;
  1760. /**
  1761. * Gets an unique (relatively to the current scene) Id
  1762. * @returns an unique number for the scene
  1763. */
  1764. getUniqueId(): number;
  1765. /**
  1766. * Add a mesh to the list of scene's meshes
  1767. * @param newMesh defines the mesh to add
  1768. * @param recursive if all child meshes should also be added to the scene
  1769. */
  1770. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1771. /**
  1772. * Remove a mesh for the list of scene's meshes
  1773. * @param toRemove defines the mesh to remove
  1774. * @param recursive if all child meshes should also be removed from the scene
  1775. * @returns the index where the mesh was in the mesh list
  1776. */
  1777. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1778. /**
  1779. * Add a transform node to the list of scene's transform nodes
  1780. * @param newTransformNode defines the transform node to add
  1781. */
  1782. addTransformNode(newTransformNode: TransformNode): void;
  1783. /**
  1784. * Remove a transform node for the list of scene's transform nodes
  1785. * @param toRemove defines the transform node to remove
  1786. * @returns the index where the transform node was in the transform node list
  1787. */
  1788. removeTransformNode(toRemove: TransformNode): number;
  1789. /**
  1790. * Remove a skeleton for the list of scene's skeletons
  1791. * @param toRemove defines the skeleton to remove
  1792. * @returns the index where the skeleton was in the skeleton list
  1793. */
  1794. removeSkeleton(toRemove: Skeleton): number;
  1795. /**
  1796. * Remove a morph target for the list of scene's morph targets
  1797. * @param toRemove defines the morph target to remove
  1798. * @returns the index where the morph target was in the morph target list
  1799. */
  1800. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1801. /**
  1802. * Remove a light for the list of scene's lights
  1803. * @param toRemove defines the light to remove
  1804. * @returns the index where the light was in the light list
  1805. */
  1806. removeLight(toRemove: Light): number;
  1807. /**
  1808. * Remove a camera for the list of scene's cameras
  1809. * @param toRemove defines the camera to remove
  1810. * @returns the index where the camera was in the camera list
  1811. */
  1812. removeCamera(toRemove: Camera): number;
  1813. /**
  1814. * Remove a particle system for the list of scene's particle systems
  1815. * @param toRemove defines the particle system to remove
  1816. * @returns the index where the particle system was in the particle system list
  1817. */
  1818. removeParticleSystem(toRemove: IParticleSystem): number;
  1819. /**
  1820. * Remove a animation for the list of scene's animations
  1821. * @param toRemove defines the animation to remove
  1822. * @returns the index where the animation was in the animation list
  1823. */
  1824. removeAnimation(toRemove: Animation): number;
  1825. /**
  1826. * Removes the given animation group from this scene.
  1827. * @param toRemove The animation group to remove
  1828. * @returns The index of the removed animation group
  1829. */
  1830. removeAnimationGroup(toRemove: AnimationGroup): number;
  1831. /**
  1832. * Removes the given multi-material from this scene.
  1833. * @param toRemove The multi-material to remove
  1834. * @returns The index of the removed multi-material
  1835. */
  1836. removeMultiMaterial(toRemove: MultiMaterial): number;
  1837. /**
  1838. * Removes the given material from this scene.
  1839. * @param toRemove The material to remove
  1840. * @returns The index of the removed material
  1841. */
  1842. removeMaterial(toRemove: Material): number;
  1843. /**
  1844. * Removes the given action manager from this scene.
  1845. * @param toRemove The action manager to remove
  1846. * @returns The index of the removed action manager
  1847. */
  1848. removeActionManager(toRemove: ActionManager): number;
  1849. /**
  1850. * Removes the given texture from this scene.
  1851. * @param toRemove The texture to remove
  1852. * @returns The index of the removed texture
  1853. */
  1854. removeTexture(toRemove: BaseTexture): number;
  1855. /**
  1856. * Adds the given light to this scene
  1857. * @param newLight The light to add
  1858. */
  1859. addLight(newLight: Light): void;
  1860. /**
  1861. * Sorts the list list based on light priorities
  1862. */
  1863. sortLightsByPriority(): void;
  1864. /**
  1865. * Adds the given camera to this scene
  1866. * @param newCamera The camera to add
  1867. */
  1868. addCamera(newCamera: Camera): void;
  1869. /**
  1870. * Adds the given skeleton to this scene
  1871. * @param newSkeleton The skeleton to add
  1872. */
  1873. addSkeleton(newSkeleton: Skeleton): void;
  1874. /**
  1875. * Adds the given particle system to this scene
  1876. * @param newParticleSystem The particle system to add
  1877. */
  1878. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1879. /**
  1880. * Adds the given animation to this scene
  1881. * @param newAnimation The animation to add
  1882. */
  1883. addAnimation(newAnimation: Animation): void;
  1884. /**
  1885. * Adds the given animation group to this scene.
  1886. * @param newAnimationGroup The animation group to add
  1887. */
  1888. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1889. /**
  1890. * Adds the given multi-material to this scene
  1891. * @param newMultiMaterial The multi-material to add
  1892. */
  1893. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1894. /**
  1895. * Adds the given material to this scene
  1896. * @param newMaterial The material to add
  1897. */
  1898. addMaterial(newMaterial: Material): void;
  1899. /**
  1900. * Adds the given morph target to this scene
  1901. * @param newMorphTargetManager The morph target to add
  1902. */
  1903. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1904. /**
  1905. * Adds the given geometry to this scene
  1906. * @param newGeometry The geometry to add
  1907. */
  1908. addGeometry(newGeometry: Geometry): void;
  1909. /**
  1910. * Adds the given action manager to this scene
  1911. * @param newActionManager The action manager to add
  1912. */
  1913. addActionManager(newActionManager: ActionManager): void;
  1914. /**
  1915. * Adds the given texture to this scene.
  1916. * @param newTexture The texture to add
  1917. */
  1918. addTexture(newTexture: BaseTexture): void;
  1919. /**
  1920. * Switch active camera
  1921. * @param newCamera defines the new active camera
  1922. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1923. */
  1924. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1925. /**
  1926. * sets the active camera of the scene using its ID
  1927. * @param id defines the camera's ID
  1928. * @return the new active camera or null if none found.
  1929. */
  1930. setActiveCameraByID(id: string): Nullable<Camera>;
  1931. /**
  1932. * sets the active camera of the scene using its name
  1933. * @param name defines the camera's name
  1934. * @returns the new active camera or null if none found.
  1935. */
  1936. setActiveCameraByName(name: string): Nullable<Camera>;
  1937. /**
  1938. * get an animation group using its name
  1939. * @param name defines the material's name
  1940. * @return the animation group or null if none found.
  1941. */
  1942. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1943. /**
  1944. * get a material using its id
  1945. * @param id defines the material's ID
  1946. * @return the material or null if none found.
  1947. */
  1948. getMaterialByID(id: string): Nullable<Material>;
  1949. /**
  1950. * Gets a material using its name
  1951. * @param name defines the material's name
  1952. * @return the material or null if none found.
  1953. */
  1954. getMaterialByName(name: string): Nullable<Material>;
  1955. /**
  1956. * Gets a camera using its id
  1957. * @param id defines the id to look for
  1958. * @returns the camera or null if not found
  1959. */
  1960. getCameraByID(id: string): Nullable<Camera>;
  1961. /**
  1962. * Gets a camera using its unique id
  1963. * @param uniqueId defines the unique id to look for
  1964. * @returns the camera or null if not found
  1965. */
  1966. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1967. /**
  1968. * Gets a camera using its name
  1969. * @param name defines the camera's name
  1970. * @return the camera or null if none found.
  1971. */
  1972. getCameraByName(name: string): Nullable<Camera>;
  1973. /**
  1974. * Gets a bone using its id
  1975. * @param id defines the bone's id
  1976. * @return the bone or null if not found
  1977. */
  1978. getBoneByID(id: string): Nullable<Bone>;
  1979. /**
  1980. * Gets a bone using its id
  1981. * @param name defines the bone's name
  1982. * @return the bone or null if not found
  1983. */
  1984. getBoneByName(name: string): Nullable<Bone>;
  1985. /**
  1986. * Gets a light node using its name
  1987. * @param name defines the the light's name
  1988. * @return the light or null if none found.
  1989. */
  1990. getLightByName(name: string): Nullable<Light>;
  1991. /**
  1992. * Gets a light node using its id
  1993. * @param id defines the light's id
  1994. * @return the light or null if none found.
  1995. */
  1996. getLightByID(id: string): Nullable<Light>;
  1997. /**
  1998. * Gets a light node using its scene-generated unique ID
  1999. * @param uniqueId defines the light's unique id
  2000. * @return the light or null if none found.
  2001. */
  2002. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2003. /**
  2004. * Gets a particle system by id
  2005. * @param id defines the particle system id
  2006. * @return the corresponding system or null if none found
  2007. */
  2008. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2009. /**
  2010. * Gets a geometry using its ID
  2011. * @param id defines the geometry's id
  2012. * @return the geometry or null if none found.
  2013. */
  2014. getGeometryByID(id: string): Nullable<Geometry>;
  2015. /**
  2016. * Add a new geometry to this scene
  2017. * @param geometry defines the geometry to be added to the scene.
  2018. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2019. * @return a boolean defining if the geometry was added or not
  2020. */
  2021. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2022. /**
  2023. * Removes an existing geometry
  2024. * @param geometry defines the geometry to be removed from the scene
  2025. * @return a boolean defining if the geometry was removed or not
  2026. */
  2027. removeGeometry(geometry: Geometry): boolean;
  2028. /**
  2029. * Gets the list of geometries attached to the scene
  2030. * @returns an array of Geometry
  2031. */
  2032. getGeometries(): Geometry[];
  2033. /**
  2034. * Gets the first added mesh found of a given ID
  2035. * @param id defines the id to search for
  2036. * @return the mesh found or null if not found at all
  2037. */
  2038. getMeshByID(id: string): Nullable<AbstractMesh>;
  2039. /**
  2040. * Gets a list of meshes using their id
  2041. * @param id defines the id to search for
  2042. * @returns a list of meshes
  2043. */
  2044. getMeshesByID(id: string): Array<AbstractMesh>;
  2045. /**
  2046. * Gets the first added transform node found of a given ID
  2047. * @param id defines the id to search for
  2048. * @return the found transform node or null if not found at all.
  2049. */
  2050. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2051. /**
  2052. * Gets a list of transform nodes using their id
  2053. * @param id defines the id to search for
  2054. * @returns a list of transform nodes
  2055. */
  2056. getTransformNodesByID(id: string): Array<TransformNode>;
  2057. /**
  2058. * Gets a mesh with its auto-generated unique id
  2059. * @param uniqueId defines the unique id to search for
  2060. * @return the found mesh or null if not found at all.
  2061. */
  2062. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2063. /**
  2064. * Gets a the last added mesh using a given id
  2065. * @param id defines the id to search for
  2066. * @return the found mesh or null if not found at all.
  2067. */
  2068. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2069. /**
  2070. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2071. * @param id defines the id to search for
  2072. * @return the found node or null if not found at all
  2073. */
  2074. getLastEntryByID(id: string): Nullable<Node>;
  2075. /**
  2076. * Gets a node (Mesh, Camera, Light) using a given id
  2077. * @param id defines the id to search for
  2078. * @return the found node or null if not found at all
  2079. */
  2080. getNodeByID(id: string): Nullable<Node>;
  2081. /**
  2082. * Gets a node (Mesh, Camera, Light) using a given name
  2083. * @param name defines the name to search for
  2084. * @return the found node or null if not found at all.
  2085. */
  2086. getNodeByName(name: string): Nullable<Node>;
  2087. /**
  2088. * Gets a mesh using a given name
  2089. * @param name defines the name to search for
  2090. * @return the found mesh or null if not found at all.
  2091. */
  2092. getMeshByName(name: string): Nullable<AbstractMesh>;
  2093. /**
  2094. * Gets a transform node using a given name
  2095. * @param name defines the name to search for
  2096. * @return the found transform node or null if not found at all.
  2097. */
  2098. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2099. /**
  2100. * Gets a sound using a given name
  2101. * @param name defines the name to search for
  2102. * @return the found sound or null if not found at all.
  2103. */
  2104. getSoundByName(name: string): Nullable<Sound>;
  2105. /**
  2106. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2107. * @param id defines the id to search for
  2108. * @return the found skeleton or null if not found at all.
  2109. */
  2110. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2111. /**
  2112. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2113. * @param id defines the id to search for
  2114. * @return the found skeleton or null if not found at all.
  2115. */
  2116. getSkeletonById(id: string): Nullable<Skeleton>;
  2117. /**
  2118. * Gets a skeleton using a given name
  2119. * @param name defines the name to search for
  2120. * @return the found skeleton or null if not found at all.
  2121. */
  2122. getSkeletonByName(name: string): Nullable<Skeleton>;
  2123. /**
  2124. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2125. * @param id defines the id to search for
  2126. * @return the found morph target manager or null if not found at all.
  2127. */
  2128. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2129. /**
  2130. * Gets a boolean indicating if the given mesh is active
  2131. * @param mesh defines the mesh to look for
  2132. * @returns true if the mesh is in the active list
  2133. */
  2134. isActiveMesh(mesh: AbstractMesh): boolean;
  2135. /**
  2136. * Return a unique id as a string which can serve as an identifier for the scene
  2137. */
  2138. readonly uid: string;
  2139. /**
  2140. * Add an externaly attached data from its key.
  2141. * This method call will fail and return false, if such key already exists.
  2142. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2143. * @param key the unique key that identifies the data
  2144. * @param data the data object to associate to the key for this Engine instance
  2145. * @return true if no such key were already present and the data was added successfully, false otherwise
  2146. */
  2147. addExternalData<T>(key: string, data: T): boolean;
  2148. /**
  2149. * Get an externaly attached data from its key
  2150. * @param key the unique key that identifies the data
  2151. * @return the associated data, if present (can be null), or undefined if not present
  2152. */
  2153. getExternalData<T>(key: string): Nullable<T>;
  2154. /**
  2155. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2156. * @param key the unique key that identifies the data
  2157. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2158. * @return the associated data, can be null if the factory returned null.
  2159. */
  2160. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2161. /**
  2162. * Remove an externaly attached data from the Engine instance
  2163. * @param key the unique key that identifies the data
  2164. * @return true if the data was successfully removed, false if it doesn't exist
  2165. */
  2166. removeExternalData(key: string): boolean;
  2167. private _evaluateSubMesh;
  2168. /**
  2169. * Clear the processed materials smart array preventing retention point in material dispose.
  2170. */
  2171. freeProcessedMaterials(): void;
  2172. /**
  2173. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2174. */
  2175. freeActiveMeshes(): void;
  2176. /**
  2177. * Clear the info related to rendering groups preventing retention points during dispose.
  2178. */
  2179. freeRenderingGroups(): void;
  2180. /** @hidden */
  2181. _isInIntermediateRendering(): boolean;
  2182. private _activeMeshCandidateProvider;
  2183. /**
  2184. * Defines the current active mesh candidate provider
  2185. * @param provider defines the provider to use
  2186. */
  2187. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2188. /**
  2189. * Gets the current active mesh candidate provider
  2190. * @returns the current active mesh candidate provider
  2191. */
  2192. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2193. private _activeMeshesFrozen;
  2194. /**
  2195. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2196. * @returns the current scene
  2197. */
  2198. freezeActiveMeshes(): Scene;
  2199. /**
  2200. * Use this function to restart evaluating active meshes on every frame
  2201. * @returns the current scene
  2202. */
  2203. unfreezeActiveMeshes(): Scene;
  2204. private _evaluateActiveMeshes;
  2205. private _activeMesh;
  2206. /**
  2207. * Update the transform matrix to update from the current active camera
  2208. * @param force defines a boolean used to force the update even if cache is up to date
  2209. */
  2210. updateTransformMatrix(force?: boolean): void;
  2211. /**
  2212. * 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)
  2213. * @param alternateCamera defines the camera to use
  2214. */
  2215. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2216. /** @hidden */
  2217. _allowPostProcessClear: boolean;
  2218. private _renderForCamera;
  2219. private _processSubCameras;
  2220. private _checkIntersections;
  2221. /**
  2222. * Render the scene
  2223. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2224. */
  2225. render(updateCameras?: boolean): void;
  2226. private _updateAudioParameters;
  2227. /**
  2228. * Gets or sets if audio support is enabled
  2229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2230. */
  2231. audioEnabled: boolean;
  2232. private _disableAudio;
  2233. private _enableAudio;
  2234. /**
  2235. * Gets or sets if audio will be output to headphones
  2236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2237. */
  2238. headphone: boolean;
  2239. private _switchAudioModeForHeadphones;
  2240. private _switchAudioModeForNormalSpeakers;
  2241. /**
  2242. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2243. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2244. * @returns the created depth renderer
  2245. */
  2246. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2247. /**
  2248. * Disables a depth renderer for a given camera
  2249. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2250. */
  2251. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2252. /**
  2253. * Enables a GeometryBufferRender and associates it with the scene
  2254. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2255. * @returns the GeometryBufferRenderer
  2256. */
  2257. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2258. /**
  2259. * Disables the GeometryBufferRender associated with the scene
  2260. */
  2261. disableGeometryBufferRenderer(): void;
  2262. /**
  2263. * Freeze all materials
  2264. * A frozen material will not be updatable but should be faster to render
  2265. */
  2266. freezeMaterials(): void;
  2267. /**
  2268. * Unfreeze all materials
  2269. * A frozen material will not be updatable but should be faster to render
  2270. */
  2271. unfreezeMaterials(): void;
  2272. /**
  2273. * Releases all held ressources
  2274. */
  2275. dispose(): void;
  2276. /**
  2277. * Gets if the scene is already disposed
  2278. */
  2279. readonly isDisposed: boolean;
  2280. /**
  2281. * Releases sounds & soundtracks
  2282. */
  2283. disposeSounds(): void;
  2284. /**
  2285. * Call this function to reduce memory footprint of the scene.
  2286. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2287. */
  2288. clearCachedVertexData(): void;
  2289. /**
  2290. * This function will remove the local cached buffer data from texture.
  2291. * It will save memory but will prevent the texture from being rebuilt
  2292. */
  2293. cleanCachedTextureBuffer(): void;
  2294. /**
  2295. * Get the world extend vectors with an optional filter
  2296. *
  2297. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2298. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2299. */
  2300. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2301. min: Vector3;
  2302. max: Vector3;
  2303. };
  2304. /**
  2305. * Creates or updates the octree used to boost selection (picking)
  2306. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2307. * @param maxCapacity defines the maximum capacity per leaf
  2308. * @param maxDepth defines the maximum depth of the octree
  2309. * @returns an octree of AbstractMesh
  2310. */
  2311. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2312. /**
  2313. * Creates a ray that can be used to pick in the scene
  2314. * @param x defines the x coordinate of the origin (on-screen)
  2315. * @param y defines the y coordinate of the origin (on-screen)
  2316. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2317. * @param camera defines the camera to use for the picking
  2318. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2319. * @returns a Ray
  2320. */
  2321. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2322. /**
  2323. * Creates a ray that can be used to pick in the scene
  2324. * @param x defines the x coordinate of the origin (on-screen)
  2325. * @param y defines the y coordinate of the origin (on-screen)
  2326. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2327. * @param result defines the ray where to store the picking ray
  2328. * @param camera defines the camera to use for the picking
  2329. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2330. * @returns the current scene
  2331. */
  2332. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2333. /**
  2334. * Creates a ray that can be used to pick in the scene
  2335. * @param x defines the x coordinate of the origin (on-screen)
  2336. * @param y defines the y coordinate of the origin (on-screen)
  2337. * @param camera defines the camera to use for the picking
  2338. * @returns a Ray
  2339. */
  2340. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2341. /**
  2342. * Creates a ray that can be used to pick in the scene
  2343. * @param x defines the x coordinate of the origin (on-screen)
  2344. * @param y defines the y coordinate of the origin (on-screen)
  2345. * @param result defines the ray where to store the picking ray
  2346. * @param camera defines the camera to use for the picking
  2347. * @returns the current scene
  2348. */
  2349. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2350. private _internalPick;
  2351. private _internalMultiPick;
  2352. private _internalPickSprites;
  2353. private _tempPickingRay;
  2354. /** Launch a ray to try to pick a mesh in the scene
  2355. * @param x position on screen
  2356. * @param y position on screen
  2357. * @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
  2358. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2359. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2360. * @returns a PickingInfo
  2361. */
  2362. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2363. /** Launch a ray to try to pick a sprite in the scene
  2364. * @param x position on screen
  2365. * @param y position on screen
  2366. * @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
  2367. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2368. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2369. * @returns a PickingInfo
  2370. */
  2371. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2372. private _cachedRayForTransform;
  2373. /** Use the given ray to pick a mesh in the scene
  2374. * @param ray The ray to use to pick meshes
  2375. * @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
  2376. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2377. * @returns a PickingInfo
  2378. */
  2379. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2380. /**
  2381. * Launch a ray to try to pick a mesh in the scene
  2382. * @param x X position on screen
  2383. * @param y Y position on screen
  2384. * @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
  2385. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2386. * @returns an array of PickingInfo
  2387. */
  2388. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2389. /**
  2390. * Launch a ray to try to pick a mesh in the scene
  2391. * @param ray Ray to use
  2392. * @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
  2393. * @returns an array of PickingInfo
  2394. */
  2395. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2396. /**
  2397. * Force the value of meshUnderPointer
  2398. * @param mesh defines the mesh to use
  2399. */
  2400. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2401. /**
  2402. * Gets the mesh under the pointer
  2403. * @returns a Mesh or null if no mesh is under the pointer
  2404. */
  2405. getPointerOverMesh(): Nullable<AbstractMesh>;
  2406. /**
  2407. * Force the sprite under the pointer
  2408. * @param sprite defines the sprite to use
  2409. */
  2410. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2411. /**
  2412. * Gets the sprite under the pointer
  2413. * @returns a Sprite or null if no sprite is under the pointer
  2414. */
  2415. getPointerOverSprite(): Nullable<Sprite>;
  2416. /**
  2417. * Gets the current physics engine
  2418. * @returns a PhysicsEngine or null if none attached
  2419. */
  2420. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2421. /**
  2422. * Enables physics to the current scene
  2423. * @param gravity defines the scene's gravity for the physics engine
  2424. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2425. * @return a boolean indicating if the physics engine was initialized
  2426. */
  2427. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2428. /**
  2429. * Disables and disposes the physics engine associated with the scene
  2430. */
  2431. disablePhysicsEngine(): void;
  2432. /**
  2433. * Gets a boolean indicating if there is an active physics engine
  2434. * @returns a boolean indicating if there is an active physics engine
  2435. */
  2436. isPhysicsEnabled(): boolean;
  2437. /**
  2438. * Deletes a physics compound impostor
  2439. * @param compound defines the compound to delete
  2440. */
  2441. deleteCompoundImpostor(compound: any): void;
  2442. /** @hidden */
  2443. _rebuildGeometries(): void;
  2444. /** @hidden */
  2445. _rebuildTextures(): void;
  2446. /**
  2447. * Creates a default light for the scene.
  2448. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  2449. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  2450. */
  2451. createDefaultLight(replace?: boolean): void;
  2452. /**
  2453. * Creates a default camera for the scene.
  2454. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  2455. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2456. * @param replace has default false, when true replaces the active camera in the scene
  2457. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  2458. */
  2459. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2460. /**
  2461. * Creates a default camera and a default light.
  2462. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  2463. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2464. * @param replace has the default false, when true replaces the active camera/light in the scene
  2465. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  2466. */
  2467. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2468. /**
  2469. * Creates a new sky box
  2470. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  2471. * @param environmentTexture defines the texture to use as environment texture
  2472. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  2473. * @param scale defines the overall scale of the skybox
  2474. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  2475. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  2476. * @returns a new mesh holding the sky box
  2477. */
  2478. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2479. /**
  2480. * Creates a new environment
  2481. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  2482. * @param options defines the options you can use to configure the environment
  2483. * @returns the new EnvironmentHelper
  2484. */
  2485. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2486. /**
  2487. * Creates a new VREXperienceHelper
  2488. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2489. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2490. * @returns a new VREXperienceHelper
  2491. */
  2492. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2493. private _getByTags;
  2494. /**
  2495. * Get a list of meshes by tags
  2496. * @param tagsQuery defines the tags query to use
  2497. * @param forEach defines a predicate used to filter results
  2498. * @returns an array of Mesh
  2499. */
  2500. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2501. /**
  2502. * Get a list of cameras by tags
  2503. * @param tagsQuery defines the tags query to use
  2504. * @param forEach defines a predicate used to filter results
  2505. * @returns an array of Camera
  2506. */
  2507. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2508. /**
  2509. * Get a list of lights by tags
  2510. * @param tagsQuery defines the tags query to use
  2511. * @param forEach defines a predicate used to filter results
  2512. * @returns an array of Light
  2513. */
  2514. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2515. /**
  2516. * Get a list of materials by tags
  2517. * @param tagsQuery defines the tags query to use
  2518. * @param forEach defines a predicate used to filter results
  2519. * @returns an array of Material
  2520. */
  2521. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2522. /**
  2523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2524. * This allowed control for front to back rendering or reversly depending of the special needs.
  2525. *
  2526. * @param renderingGroupId The rendering group id corresponding to its index
  2527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2530. */
  2531. 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;
  2532. /**
  2533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2534. *
  2535. * @param renderingGroupId The rendering group id corresponding to its index
  2536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2539. */
  2540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2541. /**
  2542. * Gets the current auto clear configuration for one rendering group of the rendering
  2543. * manager.
  2544. * @param index the rendering group index to get the information for
  2545. * @returns The auto clear setup for the requested rendering group
  2546. */
  2547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2548. /**
  2549. * Will flag all materials as dirty to trigger new shader compilation
  2550. * @param flag defines the flag used to specify which material part must be marked as dirty
  2551. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2552. */
  2553. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2554. /** @hidden */
  2555. _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;
  2556. /** @hidden */
  2557. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2558. }
  2559. }
  2560. declare module BABYLON {
  2561. /**
  2562. * Groups all the scene component constants in one place to ease maintenance.
  2563. * @hidden
  2564. */
  2565. class SceneComponentConstants {
  2566. static readonly NAME_EFFECTLAYER: string;
  2567. static readonly NAME_LAYER: string;
  2568. static readonly NAME_LENSFLARESYSTEM: string;
  2569. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2570. static readonly NAME_PARTICLESYSTEM: string;
  2571. static readonly NAME_GAMEPAD: string;
  2572. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2573. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2574. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2575. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2576. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2577. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2578. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2579. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2580. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2581. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2582. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2583. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2584. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2585. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2586. }
  2587. /**
  2588. * This represents a scene component.
  2589. *
  2590. * This is used to decouple the dependency the scene is having on the different workloads like
  2591. * layers, post processes...
  2592. */
  2593. interface ISceneComponent {
  2594. /**
  2595. * The name of the component. Each component must have a unique name.
  2596. */
  2597. name: string;
  2598. /**
  2599. * The scene the component belongs to.
  2600. */
  2601. scene: Scene;
  2602. /**
  2603. * Register the component to one instance of a scene.
  2604. */
  2605. register(): void;
  2606. /**
  2607. * Rebuilds the elements related to this component in case of
  2608. * context lost for instance.
  2609. */
  2610. rebuild(): void;
  2611. /**
  2612. * Disposes the component and the associated ressources.
  2613. */
  2614. dispose(): void;
  2615. }
  2616. /**
  2617. * This represents a SERIALIZABLE scene component.
  2618. *
  2619. * This extends Scene Component to add Serialization methods on top.
  2620. */
  2621. interface ISceneSerializableComponent extends ISceneComponent {
  2622. /**
  2623. * Adds all the element from the container to the scene
  2624. * @param container the container holding the elements
  2625. */
  2626. addFromContainer(container: AbstractScene): void;
  2627. /**
  2628. * Removes all the elements in the container from the scene
  2629. * @param container contains the elements to remove
  2630. */
  2631. removeFromContainer(container: AbstractScene): void;
  2632. /**
  2633. * Serializes the component data to the specified json object
  2634. * @param serializationObject The object to serialize to
  2635. */
  2636. serialize(serializationObject: any): void;
  2637. }
  2638. /**
  2639. * Strong typing of a Mesh related stage step action
  2640. */
  2641. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2642. /**
  2643. * Strong typing of a Evaluate Sub Mesh related stage step action
  2644. */
  2645. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2646. /**
  2647. * Strong typing of a Active Mesh related stage step action
  2648. */
  2649. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2650. /**
  2651. * Strong typing of a Camera related stage step action
  2652. */
  2653. type CameraStageAction = (camera: Camera) => void;
  2654. /**
  2655. * Strong typing of a RenderingGroup related stage step action
  2656. */
  2657. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2658. /**
  2659. * Strong typing of a simple stage step action
  2660. */
  2661. type SimpleStageAction = () => void;
  2662. /**
  2663. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2664. * @hidden
  2665. */
  2666. class Stage<T extends Function> extends Array<{
  2667. index: number;
  2668. component: ISceneComponent;
  2669. action: T;
  2670. }> {
  2671. /**
  2672. * Hide ctor from the rest of the world.
  2673. * @param items The items to add.
  2674. */
  2675. private constructor();
  2676. /**
  2677. * Creates a new Stage.
  2678. * @returns A new instance of a Stage
  2679. */
  2680. static Create<T extends Function>(): Stage<T>;
  2681. /**
  2682. * Registers a step in an ordered way in the targeted stage.
  2683. * @param index Defines the position to register the step in
  2684. * @param component Defines the component attached to the step
  2685. * @param action Defines the action to launch during the step
  2686. */
  2687. registerStep(index: number, component: ISceneComponent, action: T): void;
  2688. /**
  2689. * Clears all the steps from the stage.
  2690. */
  2691. clear(): void;
  2692. }
  2693. }
  2694. declare module BABYLON {
  2695. type Nullable<T> = T | null;
  2696. type float = number;
  2697. type double = number;
  2698. type int = number;
  2699. type FloatArray = number[] | Float32Array;
  2700. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2701. /**
  2702. * Alias for types that can be used by a Buffer or VertexBuffer.
  2703. */
  2704. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2705. }
  2706. declare module BABYLON {
  2707. /**
  2708. * The action to be carried out following a trigger
  2709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2710. */
  2711. class Action {
  2712. /** the trigger, with or without parameters, for the action */
  2713. triggerOptions: any;
  2714. /**
  2715. * Trigger for the action
  2716. */
  2717. trigger: number;
  2718. /**
  2719. * Internal only - manager for action
  2720. * @hidden
  2721. */
  2722. _actionManager: ActionManager;
  2723. private _nextActiveAction;
  2724. private _child;
  2725. private _condition?;
  2726. private _triggerParameter;
  2727. /**
  2728. * An event triggered prior to action being executed.
  2729. */
  2730. onBeforeExecuteObservable: Observable<Action>;
  2731. /**
  2732. * Creates a new Action
  2733. * @param triggerOptions the trigger, with or without parameters, for the action
  2734. * @param condition an optional determinant of action
  2735. */
  2736. constructor(
  2737. /** the trigger, with or without parameters, for the action */
  2738. triggerOptions: any, condition?: Condition);
  2739. /**
  2740. * Internal only
  2741. * @hidden
  2742. */
  2743. _prepare(): void;
  2744. /**
  2745. * Gets the trigger parameters
  2746. * @returns the trigger parameters
  2747. */
  2748. getTriggerParameter(): any;
  2749. /**
  2750. * Internal only - executes current action event
  2751. * @hidden
  2752. */
  2753. _executeCurrent(evt?: ActionEvent): void;
  2754. /**
  2755. * Execute placeholder for child classes
  2756. * @param evt optional action event
  2757. */
  2758. execute(evt?: ActionEvent): void;
  2759. /**
  2760. * Skips to next active action
  2761. */
  2762. skipToNextActiveAction(): void;
  2763. /**
  2764. * Adds action to chain of actions, may be a DoNothingAction
  2765. * @param action defines the next action to execute
  2766. * @returns The action passed in
  2767. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2768. */
  2769. then(action: Action): Action;
  2770. /**
  2771. * Internal only
  2772. * @hidden
  2773. */
  2774. _getProperty(propertyPath: string): string;
  2775. /**
  2776. * Internal only
  2777. * @hidden
  2778. */
  2779. _getEffectiveTarget(target: any, propertyPath: string): any;
  2780. /**
  2781. * Serialize placeholder for child classes
  2782. * @param parent of child
  2783. * @returns the serialized object
  2784. */
  2785. serialize(parent: any): any;
  2786. /**
  2787. * Internal only called by serialize
  2788. * @hidden
  2789. */
  2790. protected _serialize(serializedAction: any, parent?: any): any;
  2791. /**
  2792. * Internal only
  2793. * @hidden
  2794. */
  2795. static _SerializeValueAsString: (value: any) => string;
  2796. /**
  2797. * Internal only
  2798. * @hidden
  2799. */
  2800. static _GetTargetProperty: (target: Scene | Node) => {
  2801. name: string;
  2802. targetType: string;
  2803. value: string;
  2804. };
  2805. }
  2806. }
  2807. declare module BABYLON {
  2808. /**
  2809. * ActionEvent is the event being sent when an action is triggered.
  2810. */
  2811. class ActionEvent {
  2812. /** The mesh or sprite that triggered the action */
  2813. source: any;
  2814. /** The X mouse cursor position at the time of the event */
  2815. pointerX: number;
  2816. /** The Y mouse cursor position at the time of the event */
  2817. pointerY: number;
  2818. /** The mesh that is currently pointed at (can be null) */
  2819. meshUnderPointer: Nullable<AbstractMesh>;
  2820. /** the original (browser) event that triggered the ActionEvent */
  2821. sourceEvent?: any;
  2822. /** additional data for the event */
  2823. additionalData?: any;
  2824. /**
  2825. * Creates a new ActionEvent
  2826. * @param source The mesh or sprite that triggered the action
  2827. * @param pointerX The X mouse cursor position at the time of the event
  2828. * @param pointerY The Y mouse cursor position at the time of the event
  2829. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2830. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2831. * @param additionalData additional data for the event
  2832. */
  2833. constructor(
  2834. /** The mesh or sprite that triggered the action */
  2835. source: any,
  2836. /** The X mouse cursor position at the time of the event */
  2837. pointerX: number,
  2838. /** The Y mouse cursor position at the time of the event */
  2839. pointerY: number,
  2840. /** The mesh that is currently pointed at (can be null) */
  2841. meshUnderPointer: Nullable<AbstractMesh>,
  2842. /** the original (browser) event that triggered the ActionEvent */
  2843. sourceEvent?: any,
  2844. /** additional data for the event */
  2845. additionalData?: any);
  2846. /**
  2847. * Helper function to auto-create an ActionEvent from a source mesh.
  2848. * @param source The source mesh that triggered the event
  2849. * @param evt The original (browser) event
  2850. * @param additionalData additional data for the event
  2851. * @returns the new ActionEvent
  2852. */
  2853. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2854. /**
  2855. * Helper function to auto-create an ActionEvent from a source sprite
  2856. * @param source The source sprite that triggered the event
  2857. * @param scene Scene associated with the sprite
  2858. * @param evt The original (browser) event
  2859. * @param additionalData additional data for the event
  2860. * @returns the new ActionEvent
  2861. */
  2862. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2863. /**
  2864. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2865. * @param scene the scene where the event occurred
  2866. * @param evt The original (browser) event
  2867. * @returns the new ActionEvent
  2868. */
  2869. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2870. /**
  2871. * Helper function to auto-create an ActionEvent from a primitive
  2872. * @param prim defines the target primitive
  2873. * @param pointerPos defines the pointer position
  2874. * @param evt The original (browser) event
  2875. * @param additionalData additional data for the event
  2876. * @returns the new ActionEvent
  2877. */
  2878. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2879. }
  2880. /**
  2881. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2882. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2884. */
  2885. class ActionManager {
  2886. private static _NothingTrigger;
  2887. private static _OnPickTrigger;
  2888. private static _OnLeftPickTrigger;
  2889. private static _OnRightPickTrigger;
  2890. private static _OnCenterPickTrigger;
  2891. private static _OnPickDownTrigger;
  2892. private static _OnDoublePickTrigger;
  2893. private static _OnPickUpTrigger;
  2894. private static _OnLongPressTrigger;
  2895. private static _OnPointerOverTrigger;
  2896. private static _OnPointerOutTrigger;
  2897. private static _OnEveryFrameTrigger;
  2898. private static _OnIntersectionEnterTrigger;
  2899. private static _OnIntersectionExitTrigger;
  2900. private static _OnKeyDownTrigger;
  2901. private static _OnKeyUpTrigger;
  2902. private static _OnPickOutTrigger;
  2903. /**
  2904. * Nothing
  2905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2906. */
  2907. static readonly NothingTrigger: number;
  2908. /**
  2909. * On pick
  2910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2911. */
  2912. static readonly OnPickTrigger: number;
  2913. /**
  2914. * On left pick
  2915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2916. */
  2917. static readonly OnLeftPickTrigger: number;
  2918. /**
  2919. * On right pick
  2920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2921. */
  2922. static readonly OnRightPickTrigger: number;
  2923. /**
  2924. * On center pick
  2925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2926. */
  2927. static readonly OnCenterPickTrigger: number;
  2928. /**
  2929. * On pick down
  2930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2931. */
  2932. static readonly OnPickDownTrigger: number;
  2933. /**
  2934. * On double pick
  2935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2936. */
  2937. static readonly OnDoublePickTrigger: number;
  2938. /**
  2939. * On pick up
  2940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2941. */
  2942. static readonly OnPickUpTrigger: number;
  2943. /**
  2944. * On pick out.
  2945. * This trigger will only be raised if you also declared a OnPickDown
  2946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2947. */
  2948. static readonly OnPickOutTrigger: number;
  2949. /**
  2950. * On long press
  2951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2952. */
  2953. static readonly OnLongPressTrigger: number;
  2954. /**
  2955. * On pointer over
  2956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2957. */
  2958. static readonly OnPointerOverTrigger: number;
  2959. /**
  2960. * On pointer out
  2961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2962. */
  2963. static readonly OnPointerOutTrigger: number;
  2964. /**
  2965. * On every frame
  2966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2967. */
  2968. static readonly OnEveryFrameTrigger: number;
  2969. /**
  2970. * On intersection enter
  2971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2972. */
  2973. static readonly OnIntersectionEnterTrigger: number;
  2974. /**
  2975. * On intersection exit
  2976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2977. */
  2978. static readonly OnIntersectionExitTrigger: number;
  2979. /**
  2980. * On key down
  2981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2982. */
  2983. static readonly OnKeyDownTrigger: number;
  2984. /**
  2985. * On key up
  2986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2987. */
  2988. static readonly OnKeyUpTrigger: number;
  2989. /** Gets the list of active triggers */
  2990. static Triggers: {
  2991. [key: string]: number;
  2992. };
  2993. /** Gets the list of actions */
  2994. actions: Action[];
  2995. /** Gets the cursor to use when hovering items */
  2996. hoverCursor: string;
  2997. private _scene;
  2998. /**
  2999. * Creates a new action manager
  3000. * @param scene defines the hosting scene
  3001. */
  3002. constructor(scene: Scene);
  3003. /**
  3004. * Releases all associated resources
  3005. */
  3006. dispose(): void;
  3007. /**
  3008. * Gets hosting scene
  3009. * @returns the hosting scene
  3010. */
  3011. getScene(): Scene;
  3012. /**
  3013. * Does this action manager handles actions of any of the given triggers
  3014. * @param triggers defines the triggers to be tested
  3015. * @return a boolean indicating whether one (or more) of the triggers is handled
  3016. */
  3017. hasSpecificTriggers(triggers: number[]): boolean;
  3018. /**
  3019. * Does this action manager handles actions of a given trigger
  3020. * @param trigger defines the trigger to be tested
  3021. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3022. * @return whether the trigger is handled
  3023. */
  3024. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3025. /**
  3026. * Does this action manager has pointer triggers
  3027. */
  3028. readonly hasPointerTriggers: boolean;
  3029. /**
  3030. * Does this action manager has pick triggers
  3031. */
  3032. readonly hasPickTriggers: boolean;
  3033. /**
  3034. * Does exist one action manager with at least one trigger
  3035. **/
  3036. static readonly HasTriggers: boolean;
  3037. /**
  3038. * Does exist one action manager with at least one pick trigger
  3039. **/
  3040. static readonly HasPickTriggers: boolean;
  3041. /**
  3042. * Does exist one action manager that handles actions of a given trigger
  3043. * @param trigger defines the trigger to be tested
  3044. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3045. **/
  3046. static HasSpecificTrigger(trigger: number): boolean;
  3047. /**
  3048. * Registers an action to this action manager
  3049. * @param action defines the action to be registered
  3050. * @return the action amended (prepared) after registration
  3051. */
  3052. registerAction(action: Action): Nullable<Action>;
  3053. /**
  3054. * Unregisters an action to this action manager
  3055. * @param action defines the action to be unregistered
  3056. * @return a boolean indicating whether the action has been unregistered
  3057. */
  3058. unregisterAction(action: Action): Boolean;
  3059. /**
  3060. * Process a specific trigger
  3061. * @param trigger defines the trigger to process
  3062. * @param evt defines the event details to be processed
  3063. */
  3064. processTrigger(trigger: number, evt?: ActionEvent): void;
  3065. /** @hidden */
  3066. _getEffectiveTarget(target: any, propertyPath: string): any;
  3067. /** @hidden */
  3068. _getProperty(propertyPath: string): string;
  3069. /**
  3070. * Serialize this manager to a JSON object
  3071. * @param name defines the property name to store this manager
  3072. * @returns a JSON representation of this manager
  3073. */
  3074. serialize(name: string): any;
  3075. /**
  3076. * Creates a new ActionManager from a JSON data
  3077. * @param parsedActions defines the JSON data to read from
  3078. * @param object defines the hosting mesh
  3079. * @param scene defines the hosting scene
  3080. */
  3081. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3082. /**
  3083. * Get a trigger name by index
  3084. * @param trigger defines the trigger index
  3085. * @returns a trigger name
  3086. */
  3087. static GetTriggerName(trigger: number): string;
  3088. }
  3089. }
  3090. declare module BABYLON {
  3091. /**
  3092. * A Condition applied to an Action
  3093. */
  3094. class Condition {
  3095. /**
  3096. * Internal only - manager for action
  3097. * @hidden
  3098. */
  3099. _actionManager: ActionManager;
  3100. /**
  3101. * Internal only
  3102. * @hidden
  3103. */
  3104. _evaluationId: number;
  3105. /**
  3106. * Internal only
  3107. * @hidden
  3108. */
  3109. _currentResult: boolean;
  3110. /**
  3111. * Creates a new Condition
  3112. * @param actionManager the manager of the action the condition is applied to
  3113. */
  3114. constructor(actionManager: ActionManager);
  3115. /**
  3116. * Check if the current condition is valid
  3117. * @returns a boolean
  3118. */
  3119. isValid(): boolean;
  3120. /**
  3121. * Internal only
  3122. * @hidden
  3123. */
  3124. _getProperty(propertyPath: string): string;
  3125. /**
  3126. * Internal only
  3127. * @hidden
  3128. */
  3129. _getEffectiveTarget(target: any, propertyPath: string): any;
  3130. /**
  3131. * Serialize placeholder for child classes
  3132. * @returns the serialized object
  3133. */
  3134. serialize(): any;
  3135. /**
  3136. * Internal only
  3137. * @hidden
  3138. */
  3139. protected _serialize(serializedCondition: any): any;
  3140. }
  3141. /**
  3142. * Defines specific conditional operators as extensions of Condition
  3143. */
  3144. class ValueCondition extends Condition {
  3145. /** path to specify the property of the target the conditional operator uses */
  3146. propertyPath: string;
  3147. /** the value compared by the conditional operator against the current value of the property */
  3148. value: any;
  3149. /** the conditional operator, default ValueCondition.IsEqual */
  3150. operator: number;
  3151. /**
  3152. * Internal only
  3153. * @hidden
  3154. */
  3155. private static _IsEqual;
  3156. /**
  3157. * Internal only
  3158. * @hidden
  3159. */
  3160. private static _IsDifferent;
  3161. /**
  3162. * Internal only
  3163. * @hidden
  3164. */
  3165. private static _IsGreater;
  3166. /**
  3167. * Internal only
  3168. * @hidden
  3169. */
  3170. private static _IsLesser;
  3171. /**
  3172. * returns the number for IsEqual
  3173. */
  3174. static readonly IsEqual: number;
  3175. /**
  3176. * Returns the number for IsDifferent
  3177. */
  3178. static readonly IsDifferent: number;
  3179. /**
  3180. * Returns the number for IsGreater
  3181. */
  3182. static readonly IsGreater: number;
  3183. /**
  3184. * Returns the number for IsLesser
  3185. */
  3186. static readonly IsLesser: number;
  3187. /**
  3188. * Internal only The action manager for the condition
  3189. * @hidden
  3190. */
  3191. _actionManager: ActionManager;
  3192. /**
  3193. * Internal only
  3194. * @hidden
  3195. */
  3196. private _target;
  3197. /**
  3198. * Internal only
  3199. * @hidden
  3200. */
  3201. private _effectiveTarget;
  3202. /**
  3203. * Internal only
  3204. * @hidden
  3205. */
  3206. private _property;
  3207. /**
  3208. * Creates a new ValueCondition
  3209. * @param actionManager manager for the action the condition applies to
  3210. * @param target for the action
  3211. * @param propertyPath path to specify the property of the target the conditional operator uses
  3212. * @param value the value compared by the conditional operator against the current value of the property
  3213. * @param operator the conditional operator, default ValueCondition.IsEqual
  3214. */
  3215. constructor(actionManager: ActionManager, target: any,
  3216. /** path to specify the property of the target the conditional operator uses */
  3217. propertyPath: string,
  3218. /** the value compared by the conditional operator against the current value of the property */
  3219. value: any,
  3220. /** the conditional operator, default ValueCondition.IsEqual */
  3221. operator?: number);
  3222. /**
  3223. * Compares the given value with the property value for the specified conditional operator
  3224. * @returns the result of the comparison
  3225. */
  3226. isValid(): boolean;
  3227. /**
  3228. * Serialize the ValueCondition into a JSON compatible object
  3229. * @returns serialization object
  3230. */
  3231. serialize(): any;
  3232. /**
  3233. * Gets the name of the conditional operator for the ValueCondition
  3234. * @param operator the conditional operator
  3235. * @returns the name
  3236. */
  3237. static GetOperatorName(operator: number): string;
  3238. }
  3239. /**
  3240. * Defines a predicate condition as an extension of Condition
  3241. */
  3242. class PredicateCondition extends Condition {
  3243. /** defines the predicate function used to validate the condition */
  3244. predicate: () => boolean;
  3245. /**
  3246. * Internal only - manager for action
  3247. * @hidden
  3248. */
  3249. _actionManager: ActionManager;
  3250. /**
  3251. * Creates a new PredicateCondition
  3252. * @param actionManager manager for the action the condition applies to
  3253. * @param predicate defines the predicate function used to validate the condition
  3254. */
  3255. constructor(actionManager: ActionManager,
  3256. /** defines the predicate function used to validate the condition */
  3257. predicate: () => boolean);
  3258. /**
  3259. * @returns the validity of the predicate condition
  3260. */
  3261. isValid(): boolean;
  3262. }
  3263. /**
  3264. * Defines a state condition as an extension of Condition
  3265. */
  3266. class StateCondition extends Condition {
  3267. value: string;
  3268. /**
  3269. * Internal only - manager for action
  3270. * @hidden
  3271. */
  3272. _actionManager: ActionManager;
  3273. /**
  3274. * Internal only
  3275. * @hidden
  3276. */
  3277. private _target;
  3278. /**
  3279. * Creates a new StateCondition
  3280. * @param actionManager manager for the action the condition applies to
  3281. * @param target of the condition
  3282. * @param value to compare with target state
  3283. */
  3284. constructor(actionManager: ActionManager, target: any, value: string);
  3285. /**
  3286. * @returns the validity of the state
  3287. */
  3288. isValid(): boolean;
  3289. /**
  3290. * Serialize the StateCondition into a JSON compatible object
  3291. * @returns serialization object
  3292. */
  3293. serialize(): any;
  3294. }
  3295. }
  3296. declare module BABYLON {
  3297. class SwitchBooleanAction extends Action {
  3298. propertyPath: string;
  3299. private _target;
  3300. private _effectiveTarget;
  3301. private _property;
  3302. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3303. _prepare(): void;
  3304. execute(): void;
  3305. serialize(parent: any): any;
  3306. }
  3307. class SetStateAction extends Action {
  3308. value: string;
  3309. private _target;
  3310. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3311. execute(): void;
  3312. serialize(parent: any): any;
  3313. }
  3314. class SetValueAction extends Action {
  3315. propertyPath: string;
  3316. value: any;
  3317. private _target;
  3318. private _effectiveTarget;
  3319. private _property;
  3320. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3321. _prepare(): void;
  3322. execute(): void;
  3323. serialize(parent: any): any;
  3324. }
  3325. class IncrementValueAction extends Action {
  3326. propertyPath: string;
  3327. value: any;
  3328. private _target;
  3329. private _effectiveTarget;
  3330. private _property;
  3331. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3332. _prepare(): void;
  3333. execute(): void;
  3334. serialize(parent: any): any;
  3335. }
  3336. class PlayAnimationAction extends Action {
  3337. from: number;
  3338. to: number;
  3339. loop?: boolean | undefined;
  3340. private _target;
  3341. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3342. _prepare(): void;
  3343. execute(): void;
  3344. serialize(parent: any): any;
  3345. }
  3346. class StopAnimationAction extends Action {
  3347. private _target;
  3348. constructor(triggerOptions: any, target: any, condition?: Condition);
  3349. _prepare(): void;
  3350. execute(): void;
  3351. serialize(parent: any): any;
  3352. }
  3353. class DoNothingAction extends Action {
  3354. constructor(triggerOptions?: any, condition?: Condition);
  3355. execute(): void;
  3356. serialize(parent: any): any;
  3357. }
  3358. class CombineAction extends Action {
  3359. children: Action[];
  3360. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3361. _prepare(): void;
  3362. execute(evt: ActionEvent): void;
  3363. serialize(parent: any): any;
  3364. }
  3365. class ExecuteCodeAction extends Action {
  3366. func: (evt: ActionEvent) => void;
  3367. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3368. execute(evt: ActionEvent): void;
  3369. }
  3370. class SetParentAction extends Action {
  3371. private _parent;
  3372. private _target;
  3373. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3374. _prepare(): void;
  3375. execute(): void;
  3376. serialize(parent: any): any;
  3377. }
  3378. class PlaySoundAction extends Action {
  3379. private _sound;
  3380. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3381. _prepare(): void;
  3382. execute(): void;
  3383. serialize(parent: any): any;
  3384. }
  3385. class StopSoundAction extends Action {
  3386. private _sound;
  3387. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3388. _prepare(): void;
  3389. execute(): void;
  3390. serialize(parent: any): any;
  3391. }
  3392. }
  3393. declare module BABYLON {
  3394. class InterpolateValueAction extends Action {
  3395. propertyPath: string;
  3396. value: any;
  3397. duration: number;
  3398. stopOtherAnimations?: boolean | undefined;
  3399. onInterpolationDone?: (() => void) | undefined;
  3400. private _target;
  3401. private _effectiveTarget;
  3402. private _property;
  3403. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3404. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3405. _prepare(): void;
  3406. execute(): void;
  3407. serialize(parent: any): any;
  3408. }
  3409. }
  3410. declare module BABYLON {
  3411. /**
  3412. * Class used to store an actual running animation
  3413. */
  3414. class Animatable {
  3415. /** defines the target object */
  3416. target: any;
  3417. /** defines the starting frame number (default is 0) */
  3418. fromFrame: number;
  3419. /** defines the ending frame number (default is 100) */
  3420. toFrame: number;
  3421. /** defines if the animation must loop (default is false) */
  3422. loopAnimation: boolean;
  3423. /** defines a callback to call when animation ends if it is not looping */
  3424. onAnimationEnd?: (() => void) | null | undefined;
  3425. private _localDelayOffset;
  3426. private _pausedDelay;
  3427. private _runtimeAnimations;
  3428. private _paused;
  3429. private _scene;
  3430. private _speedRatio;
  3431. private _weight;
  3432. private _syncRoot;
  3433. /**
  3434. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3435. * This will only apply for non looping animation (default is true)
  3436. */
  3437. disposeOnEnd: boolean;
  3438. /**
  3439. * Gets a boolean indicating if the animation has started
  3440. */
  3441. animationStarted: boolean;
  3442. /**
  3443. * Observer raised when the animation ends
  3444. */
  3445. onAnimationEndObservable: Observable<Animatable>;
  3446. /**
  3447. * Gets the root Animatable used to synchronize and normalize animations
  3448. */
  3449. readonly syncRoot: Animatable;
  3450. /**
  3451. * Gets the current frame of the first RuntimeAnimation
  3452. * Used to synchronize Animatables
  3453. */
  3454. readonly masterFrame: number;
  3455. /**
  3456. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3457. */
  3458. weight: number;
  3459. /**
  3460. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3461. */
  3462. speedRatio: number;
  3463. /**
  3464. * Creates a new Animatable
  3465. * @param scene defines the hosting scene
  3466. * @param target defines the target object
  3467. * @param fromFrame defines the starting frame number (default is 0)
  3468. * @param toFrame defines the ending frame number (default is 100)
  3469. * @param loopAnimation defines if the animation must loop (default is false)
  3470. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3471. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3472. * @param animations defines a group of animation to add to the new Animatable
  3473. */
  3474. constructor(scene: Scene,
  3475. /** defines the target object */
  3476. target: any,
  3477. /** defines the starting frame number (default is 0) */
  3478. fromFrame?: number,
  3479. /** defines the ending frame number (default is 100) */
  3480. toFrame?: number,
  3481. /** defines if the animation must loop (default is false) */
  3482. loopAnimation?: boolean, speedRatio?: number,
  3483. /** defines a callback to call when animation ends if it is not looping */
  3484. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3485. /**
  3486. * Synchronize and normalize current Animatable with a source Animatable
  3487. * This is useful when using animation weights and when animations are not of the same length
  3488. * @param root defines the root Animatable to synchronize with
  3489. * @returns the current Animatable
  3490. */
  3491. syncWith(root: Animatable): Animatable;
  3492. /**
  3493. * Gets the list of runtime animations
  3494. * @returns an array of RuntimeAnimation
  3495. */
  3496. getAnimations(): RuntimeAnimation[];
  3497. /**
  3498. * Adds more animations to the current animatable
  3499. * @param target defines the target of the animations
  3500. * @param animations defines the new animations to add
  3501. */
  3502. appendAnimations(target: any, animations: Animation[]): void;
  3503. /**
  3504. * Gets the source animation for a specific property
  3505. * @param property defines the propertyu to look for
  3506. * @returns null or the source animation for the given property
  3507. */
  3508. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3509. /**
  3510. * Gets the runtime animation for a specific property
  3511. * @param property defines the propertyu to look for
  3512. * @returns null or the runtime animation for the given property
  3513. */
  3514. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3515. /**
  3516. * Resets the animatable to its original state
  3517. */
  3518. reset(): void;
  3519. /**
  3520. * Allows the animatable to blend with current running animations
  3521. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3522. * @param blendingSpeed defines the blending speed to use
  3523. */
  3524. enableBlending(blendingSpeed: number): void;
  3525. /**
  3526. * Disable animation blending
  3527. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3528. */
  3529. disableBlending(): void;
  3530. /**
  3531. * Jump directly to a given frame
  3532. * @param frame defines the frame to jump to
  3533. */
  3534. goToFrame(frame: number): void;
  3535. /**
  3536. * Pause the animation
  3537. */
  3538. pause(): void;
  3539. /**
  3540. * Restart the animation
  3541. */
  3542. restart(): void;
  3543. private _raiseOnAnimationEnd;
  3544. /**
  3545. * Stop and delete the current animation
  3546. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3547. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3548. */
  3549. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3550. /**
  3551. * Wait asynchronously for the animation to end
  3552. * @returns a promise which will be fullfilled when the animation ends
  3553. */
  3554. waitAsync(): Promise<Animatable>;
  3555. /** @hidden */
  3556. _animate(delay: number): boolean;
  3557. }
  3558. }
  3559. declare module BABYLON {
  3560. /**
  3561. * Represents the range of an animation
  3562. */
  3563. class AnimationRange {
  3564. /**The name of the animation range**/
  3565. name: string;
  3566. /**The starting frame of the animation */
  3567. from: number;
  3568. /**The ending frame of the animation*/
  3569. to: number;
  3570. /**
  3571. * Initializes the range of an animation
  3572. * @param name The name of the animation range
  3573. * @param from The starting frame of the animation
  3574. * @param to The ending frame of the animation
  3575. */
  3576. constructor(
  3577. /**The name of the animation range**/
  3578. name: string,
  3579. /**The starting frame of the animation */
  3580. from: number,
  3581. /**The ending frame of the animation*/
  3582. to: number);
  3583. /**
  3584. * Makes a copy of the animation range
  3585. * @returns A copy of the animation range
  3586. */
  3587. clone(): AnimationRange;
  3588. }
  3589. /**
  3590. * Composed of a frame, and an action function
  3591. */
  3592. class AnimationEvent {
  3593. /** The frame for which the event is triggered **/
  3594. frame: number;
  3595. /** The event to perform when triggered **/
  3596. action: (currentFrame: number) => void;
  3597. /** Specifies if the event should be triggered only once**/
  3598. onlyOnce?: boolean | undefined;
  3599. /**
  3600. * Specifies if the animation event is done
  3601. */
  3602. isDone: boolean;
  3603. /**
  3604. * Initializes the animation event
  3605. * @param frame The frame for which the event is triggered
  3606. * @param action The event to perform when triggered
  3607. * @param onlyOnce Specifies if the event should be triggered only once
  3608. */
  3609. constructor(
  3610. /** The frame for which the event is triggered **/
  3611. frame: number,
  3612. /** The event to perform when triggered **/
  3613. action: (currentFrame: number) => void,
  3614. /** Specifies if the event should be triggered only once**/
  3615. onlyOnce?: boolean | undefined);
  3616. /** @hidden */
  3617. _clone(): AnimationEvent;
  3618. }
  3619. /**
  3620. * A cursor which tracks a point on a path
  3621. */
  3622. class PathCursor {
  3623. private path;
  3624. /**
  3625. * Stores path cursor callbacks for when an onchange event is triggered
  3626. */
  3627. private _onchange;
  3628. /**
  3629. * The value of the path cursor
  3630. */
  3631. value: number;
  3632. /**
  3633. * The animation array of the path cursor
  3634. */
  3635. animations: Animation[];
  3636. /**
  3637. * Initializes the path cursor
  3638. * @param path The path to track
  3639. */
  3640. constructor(path: Path2);
  3641. /**
  3642. * Gets the cursor point on the path
  3643. * @returns A point on the path cursor at the cursor location
  3644. */
  3645. getPoint(): Vector3;
  3646. /**
  3647. * Moves the cursor ahead by the step amount
  3648. * @param step The amount to move the cursor forward
  3649. * @returns This path cursor
  3650. */
  3651. moveAhead(step?: number): PathCursor;
  3652. /**
  3653. * Moves the cursor behind by the step amount
  3654. * @param step The amount to move the cursor back
  3655. * @returns This path cursor
  3656. */
  3657. moveBack(step?: number): PathCursor;
  3658. /**
  3659. * Moves the cursor by the step amount
  3660. * If the step amount is greater than one, an exception is thrown
  3661. * @param step The amount to move the cursor
  3662. * @returns This path cursor
  3663. */
  3664. move(step: number): PathCursor;
  3665. /**
  3666. * Ensures that the value is limited between zero and one
  3667. * @returns This path cursor
  3668. */
  3669. private ensureLimits;
  3670. /**
  3671. * Runs onchange callbacks on change (used by the animation engine)
  3672. * @returns This path cursor
  3673. */
  3674. private raiseOnChange;
  3675. /**
  3676. * Executes a function on change
  3677. * @param f A path cursor onchange callback
  3678. * @returns This path cursor
  3679. */
  3680. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3681. }
  3682. /**
  3683. * Defines an interface which represents an animation key frame
  3684. */
  3685. interface IAnimationKey {
  3686. /**
  3687. * Frame of the key frame
  3688. */
  3689. frame: number;
  3690. /**
  3691. * Value at the specifies key frame
  3692. */
  3693. value: any;
  3694. /**
  3695. * The input tangent for the cubic hermite spline
  3696. */
  3697. inTangent?: any;
  3698. /**
  3699. * The output tangent for the cubic hermite spline
  3700. */
  3701. outTangent?: any;
  3702. /**
  3703. * The animation interpolation type
  3704. */
  3705. interpolation?: AnimationKeyInterpolation;
  3706. }
  3707. /**
  3708. * Enum for the animation key frame interpolation type
  3709. */
  3710. enum AnimationKeyInterpolation {
  3711. /**
  3712. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3713. */
  3714. STEP = 1
  3715. }
  3716. /**
  3717. * Class used to store any kind of animation
  3718. */
  3719. class Animation {
  3720. /**Name of the animation */
  3721. name: string;
  3722. /**Property to animate */
  3723. targetProperty: string;
  3724. /**The frames per second of the animation */
  3725. framePerSecond: number;
  3726. /**The data type of the animation */
  3727. dataType: number;
  3728. /**The loop mode of the animation */
  3729. loopMode?: number | undefined;
  3730. /**Specifies if blending should be enabled */
  3731. enableBlending?: boolean | undefined;
  3732. /**
  3733. * Use matrix interpolation instead of using direct key value when animating matrices
  3734. */
  3735. static AllowMatricesInterpolation: boolean;
  3736. /**
  3737. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3738. */
  3739. static AllowMatrixDecomposeForInterpolation: boolean;
  3740. /**
  3741. * Stores the key frames of the animation
  3742. */
  3743. private _keys;
  3744. /**
  3745. * Stores the easing function of the animation
  3746. */
  3747. private _easingFunction;
  3748. /**
  3749. * @hidden Internal use only
  3750. */
  3751. _runtimeAnimations: RuntimeAnimation[];
  3752. /**
  3753. * The set of event that will be linked to this animation
  3754. */
  3755. private _events;
  3756. /**
  3757. * Stores an array of target property paths
  3758. */
  3759. targetPropertyPath: string[];
  3760. /**
  3761. * Stores the blending speed of the animation
  3762. */
  3763. blendingSpeed: number;
  3764. /**
  3765. * Stores the animation ranges for the animation
  3766. */
  3767. private _ranges;
  3768. /**
  3769. * @hidden Internal use
  3770. */
  3771. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3772. /**
  3773. * Sets up an animation
  3774. * @param property The property to animate
  3775. * @param animationType The animation type to apply
  3776. * @param framePerSecond The frames per second of the animation
  3777. * @param easingFunction The easing function used in the animation
  3778. * @returns The created animation
  3779. */
  3780. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3781. /**
  3782. * Create and start an animation on a node
  3783. * @param name defines the name of the global animation that will be run on all nodes
  3784. * @param node defines the root node where the animation will take place
  3785. * @param targetProperty defines property to animate
  3786. * @param framePerSecond defines the number of frame per second yo use
  3787. * @param totalFrame defines the number of frames in total
  3788. * @param from defines the initial value
  3789. * @param to defines the final value
  3790. * @param loopMode defines which loop mode you want to use (off by default)
  3791. * @param easingFunction defines the easing function to use (linear by default)
  3792. * @param onAnimationEnd defines the callback to call when animation end
  3793. * @returns the animatable created for this animation
  3794. */
  3795. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3796. /**
  3797. * Create and start an animation on a node and its descendants
  3798. * @param name defines the name of the global animation that will be run on all nodes
  3799. * @param node defines the root node where the animation will take place
  3800. * @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
  3801. * @param targetProperty defines property to animate
  3802. * @param framePerSecond defines the number of frame per second to use
  3803. * @param totalFrame defines the number of frames in total
  3804. * @param from defines the initial value
  3805. * @param to defines the final value
  3806. * @param loopMode defines which loop mode you want to use (off by default)
  3807. * @param easingFunction defines the easing function to use (linear by default)
  3808. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3809. * @returns the list of animatables created for all nodes
  3810. * @example https://www.babylonjs-playground.com/#MH0VLI
  3811. */
  3812. 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[]>;
  3813. /**
  3814. * Creates a new animation, merges it with the existing animations and starts it
  3815. * @param name Name of the animation
  3816. * @param node Node which contains the scene that begins the animations
  3817. * @param targetProperty Specifies which property to animate
  3818. * @param framePerSecond The frames per second of the animation
  3819. * @param totalFrame The total number of frames
  3820. * @param from The frame at the beginning of the animation
  3821. * @param to The frame at the end of the animation
  3822. * @param loopMode Specifies the loop mode of the animation
  3823. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3824. * @param onAnimationEnd Callback to run once the animation is complete
  3825. * @returns Nullable animation
  3826. */
  3827. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3828. /**
  3829. * Transition property of an host to the target Value
  3830. * @param property The property to transition
  3831. * @param targetValue The target Value of the property
  3832. * @param host The object where the property to animate belongs
  3833. * @param scene Scene used to run the animation
  3834. * @param frameRate Framerate (in frame/s) to use
  3835. * @param transition The transition type we want to use
  3836. * @param duration The duration of the animation, in milliseconds
  3837. * @param onAnimationEnd Callback trigger at the end of the animation
  3838. * @returns Nullable animation
  3839. */
  3840. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3841. /**
  3842. * Return the array of runtime animations currently using this animation
  3843. */
  3844. readonly runtimeAnimations: RuntimeAnimation[];
  3845. /**
  3846. * Specifies if any of the runtime animations are currently running
  3847. */
  3848. readonly hasRunningRuntimeAnimations: boolean;
  3849. /**
  3850. * Initializes the animation
  3851. * @param name Name of the animation
  3852. * @param targetProperty Property to animate
  3853. * @param framePerSecond The frames per second of the animation
  3854. * @param dataType The data type of the animation
  3855. * @param loopMode The loop mode of the animation
  3856. * @param enableBlendings Specifies if blending should be enabled
  3857. */
  3858. constructor(
  3859. /**Name of the animation */
  3860. name: string,
  3861. /**Property to animate */
  3862. targetProperty: string,
  3863. /**The frames per second of the animation */
  3864. framePerSecond: number,
  3865. /**The data type of the animation */
  3866. dataType: number,
  3867. /**The loop mode of the animation */
  3868. loopMode?: number | undefined,
  3869. /**Specifies if blending should be enabled */
  3870. enableBlending?: boolean | undefined);
  3871. /**
  3872. * Converts the animation to a string
  3873. * @param fullDetails support for multiple levels of logging within scene loading
  3874. * @returns String form of the animation
  3875. */
  3876. toString(fullDetails?: boolean): string;
  3877. /**
  3878. * Add an event to this animation
  3879. * @param event Event to add
  3880. */
  3881. addEvent(event: AnimationEvent): void;
  3882. /**
  3883. * Remove all events found at the given frame
  3884. * @param frame The frame to remove events from
  3885. */
  3886. removeEvents(frame: number): void;
  3887. /**
  3888. * Retrieves all the events from the animation
  3889. * @returns Events from the animation
  3890. */
  3891. getEvents(): AnimationEvent[];
  3892. /**
  3893. * Creates an animation range
  3894. * @param name Name of the animation range
  3895. * @param from Starting frame of the animation range
  3896. * @param to Ending frame of the animation
  3897. */
  3898. createRange(name: string, from: number, to: number): void;
  3899. /**
  3900. * Deletes an animation range by name
  3901. * @param name Name of the animation range to delete
  3902. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3903. */
  3904. deleteRange(name: string, deleteFrames?: boolean): void;
  3905. /**
  3906. * Gets the animation range by name, or null if not defined
  3907. * @param name Name of the animation range
  3908. * @returns Nullable animation range
  3909. */
  3910. getRange(name: string): Nullable<AnimationRange>;
  3911. /**
  3912. * Gets the key frames from the animation
  3913. * @returns The key frames of the animation
  3914. */
  3915. getKeys(): Array<IAnimationKey>;
  3916. /**
  3917. * Gets the highest frame rate of the animation
  3918. * @returns Highest frame rate of the animation
  3919. */
  3920. getHighestFrame(): number;
  3921. /**
  3922. * Gets the easing function of the animation
  3923. * @returns Easing function of the animation
  3924. */
  3925. getEasingFunction(): IEasingFunction;
  3926. /**
  3927. * Sets the easing function of the animation
  3928. * @param easingFunction A custom mathematical formula for animation
  3929. */
  3930. setEasingFunction(easingFunction: EasingFunction): void;
  3931. /**
  3932. * Interpolates a scalar linearly
  3933. * @param startValue Start value of the animation curve
  3934. * @param endValue End value of the animation curve
  3935. * @param gradient Scalar amount to interpolate
  3936. * @returns Interpolated scalar value
  3937. */
  3938. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3939. /**
  3940. * Interpolates a scalar cubically
  3941. * @param startValue Start value of the animation curve
  3942. * @param outTangent End tangent of the animation
  3943. * @param endValue End value of the animation curve
  3944. * @param inTangent Start tangent of the animation curve
  3945. * @param gradient Scalar amount to interpolate
  3946. * @returns Interpolated scalar value
  3947. */
  3948. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3949. /**
  3950. * Interpolates a quaternion using a spherical linear interpolation
  3951. * @param startValue Start value of the animation curve
  3952. * @param endValue End value of the animation curve
  3953. * @param gradient Scalar amount to interpolate
  3954. * @returns Interpolated quaternion value
  3955. */
  3956. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3957. /**
  3958. * Interpolates a quaternion cubically
  3959. * @param startValue Start value of the animation curve
  3960. * @param outTangent End tangent of the animation curve
  3961. * @param endValue End value of the animation curve
  3962. * @param inTangent Start tangent of the animation curve
  3963. * @param gradient Scalar amount to interpolate
  3964. * @returns Interpolated quaternion value
  3965. */
  3966. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3967. /**
  3968. * Interpolates a Vector3 linearl
  3969. * @param startValue Start value of the animation curve
  3970. * @param endValue End value of the animation curve
  3971. * @param gradient Scalar amount to interpolate
  3972. * @returns Interpolated scalar value
  3973. */
  3974. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3975. /**
  3976. * Interpolates a Vector3 cubically
  3977. * @param startValue Start value of the animation curve
  3978. * @param outTangent End tangent of the animation
  3979. * @param endValue End value of the animation curve
  3980. * @param inTangent Start tangent of the animation curve
  3981. * @param gradient Scalar amount to interpolate
  3982. * @returns InterpolatedVector3 value
  3983. */
  3984. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3985. /**
  3986. * Interpolates a Vector2 linearly
  3987. * @param startValue Start value of the animation curve
  3988. * @param endValue End value of the animation curve
  3989. * @param gradient Scalar amount to interpolate
  3990. * @returns Interpolated Vector2 value
  3991. */
  3992. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3993. /**
  3994. * Interpolates a Vector2 cubically
  3995. * @param startValue Start value of the animation curve
  3996. * @param outTangent End tangent of the animation
  3997. * @param endValue End value of the animation curve
  3998. * @param inTangent Start tangent of the animation curve
  3999. * @param gradient Scalar amount to interpolate
  4000. * @returns Interpolated Vector2 value
  4001. */
  4002. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4003. /**
  4004. * Interpolates a size linearly
  4005. * @param startValue Start value of the animation curve
  4006. * @param endValue End value of the animation curve
  4007. * @param gradient Scalar amount to interpolate
  4008. * @returns Interpolated Size value
  4009. */
  4010. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4011. /**
  4012. * Interpolates a Color3 linearly
  4013. * @param startValue Start value of the animation curve
  4014. * @param endValue End value of the animation curve
  4015. * @param gradient Scalar amount to interpolate
  4016. * @returns Interpolated Color3 value
  4017. */
  4018. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4019. /**
  4020. * @hidden Internal use only
  4021. */
  4022. _getKeyValue(value: any): any;
  4023. /**
  4024. * @hidden Internal use only
  4025. */
  4026. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4027. /**
  4028. * Defines the function to use to interpolate matrices
  4029. * @param startValue defines the start matrix
  4030. * @param endValue defines the end matrix
  4031. * @param gradient defines the gradient between both matrices
  4032. * @param result defines an optional target matrix where to store the interpolation
  4033. * @returns the interpolated matrix
  4034. */
  4035. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4036. /**
  4037. * Makes a copy of the animation
  4038. * @returns Cloned animation
  4039. */
  4040. clone(): Animation;
  4041. /**
  4042. * Sets the key frames of the animation
  4043. * @param values The animation key frames to set
  4044. */
  4045. setKeys(values: Array<IAnimationKey>): void;
  4046. /**
  4047. * Serializes the animation to an object
  4048. * @returns Serialized object
  4049. */
  4050. serialize(): any;
  4051. /**
  4052. * Float animation type
  4053. */
  4054. private static _ANIMATIONTYPE_FLOAT;
  4055. /**
  4056. * Vector3 animation type
  4057. */
  4058. private static _ANIMATIONTYPE_VECTOR3;
  4059. /**
  4060. * Quaternion animation type
  4061. */
  4062. private static _ANIMATIONTYPE_QUATERNION;
  4063. /**
  4064. * Matrix animation type
  4065. */
  4066. private static _ANIMATIONTYPE_MATRIX;
  4067. /**
  4068. * Color3 animation type
  4069. */
  4070. private static _ANIMATIONTYPE_COLOR3;
  4071. /**
  4072. * Vector2 animation type
  4073. */
  4074. private static _ANIMATIONTYPE_VECTOR2;
  4075. /**
  4076. * Size animation type
  4077. */
  4078. private static _ANIMATIONTYPE_SIZE;
  4079. /**
  4080. * Relative Loop Mode
  4081. */
  4082. private static _ANIMATIONLOOPMODE_RELATIVE;
  4083. /**
  4084. * Cycle Loop Mode
  4085. */
  4086. private static _ANIMATIONLOOPMODE_CYCLE;
  4087. /**
  4088. * Constant Loop Mode
  4089. */
  4090. private static _ANIMATIONLOOPMODE_CONSTANT;
  4091. /**
  4092. * Get the float animation type
  4093. */
  4094. static readonly ANIMATIONTYPE_FLOAT: number;
  4095. /**
  4096. * Get the Vector3 animation type
  4097. */
  4098. static readonly ANIMATIONTYPE_VECTOR3: number;
  4099. /**
  4100. * Get the Vector2 animation type
  4101. */
  4102. static readonly ANIMATIONTYPE_VECTOR2: number;
  4103. /**
  4104. * Get the Size animation type
  4105. */
  4106. static readonly ANIMATIONTYPE_SIZE: number;
  4107. /**
  4108. * Get the Quaternion animation type
  4109. */
  4110. static readonly ANIMATIONTYPE_QUATERNION: number;
  4111. /**
  4112. * Get the Matrix animation type
  4113. */
  4114. static readonly ANIMATIONTYPE_MATRIX: number;
  4115. /**
  4116. * Get the Color3 animation type
  4117. */
  4118. static readonly ANIMATIONTYPE_COLOR3: number;
  4119. /**
  4120. * Get the Relative Loop Mode
  4121. */
  4122. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4123. /**
  4124. * Get the Cycle Loop Mode
  4125. */
  4126. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4127. /**
  4128. * Get the Constant Loop Mode
  4129. */
  4130. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4131. /** @hidden */
  4132. static _UniversalLerp(left: any, right: any, amount: number): any;
  4133. /**
  4134. * Parses an animation object and creates an animation
  4135. * @param parsedAnimation Parsed animation object
  4136. * @returns Animation object
  4137. */
  4138. static Parse(parsedAnimation: any): Animation;
  4139. /**
  4140. * Appends the serialized animations from the source animations
  4141. * @param source Source containing the animations
  4142. * @param destination Target to store the animations
  4143. */
  4144. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4145. }
  4146. }
  4147. declare module BABYLON {
  4148. /**
  4149. * This class defines the direct association between an animation and a target
  4150. */
  4151. class TargetedAnimation {
  4152. animation: Animation;
  4153. target: any;
  4154. }
  4155. /**
  4156. * Use this class to create coordinated animations on multiple targets
  4157. */
  4158. class AnimationGroup implements IDisposable {
  4159. name: string;
  4160. private _scene;
  4161. private _targetedAnimations;
  4162. private _animatables;
  4163. private _from;
  4164. private _to;
  4165. private _isStarted;
  4166. private _speedRatio;
  4167. onAnimationEndObservable: Observable<TargetedAnimation>;
  4168. /**
  4169. * This observable will notify when all animations have ended.
  4170. */
  4171. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4172. /**
  4173. * This observable will notify when all animations have paused.
  4174. */
  4175. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4176. /**
  4177. * Gets the first frame
  4178. */
  4179. readonly from: number;
  4180. /**
  4181. * Gets the last frame
  4182. */
  4183. readonly to: number;
  4184. /**
  4185. * Define if the animations are started
  4186. */
  4187. readonly isStarted: boolean;
  4188. /**
  4189. * Gets or sets the speed ratio to use for all animations
  4190. */
  4191. /**
  4192. * Gets or sets the speed ratio to use for all animations
  4193. */
  4194. speedRatio: number;
  4195. /**
  4196. * Gets the targeted animations for this animation group
  4197. */
  4198. readonly targetedAnimations: Array<TargetedAnimation>;
  4199. /**
  4200. * returning the list of animatables controlled by this animation group.
  4201. */
  4202. readonly animatables: Array<Animatable>;
  4203. constructor(name: string, scene?: Nullable<Scene>);
  4204. /**
  4205. * Add an animation (with its target) in the group
  4206. * @param animation defines the animation we want to add
  4207. * @param target defines the target of the animation
  4208. * @returns the {BABYLON.TargetedAnimation} object
  4209. */
  4210. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4211. /**
  4212. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4213. * It can add constant keys at begin or end
  4214. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4215. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4216. */
  4217. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4218. /**
  4219. * Start all animations on given targets
  4220. * @param loop defines if animations must loop
  4221. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4222. * @param from defines the from key (optional)
  4223. * @param to defines the to key (optional)
  4224. * @returns the current animation group
  4225. */
  4226. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4227. /**
  4228. * Pause all animations
  4229. */
  4230. pause(): AnimationGroup;
  4231. /**
  4232. * Play all animations to initial state
  4233. * This function will start() the animations if they were not started or will restart() them if they were paused
  4234. * @param loop defines if animations must loop
  4235. */
  4236. play(loop?: boolean): AnimationGroup;
  4237. /**
  4238. * Reset all animations to initial state
  4239. */
  4240. reset(): AnimationGroup;
  4241. /**
  4242. * Restart animations from key 0
  4243. */
  4244. restart(): AnimationGroup;
  4245. /**
  4246. * Stop all animations
  4247. */
  4248. stop(): AnimationGroup;
  4249. /**
  4250. * Set animation weight for all animatables
  4251. * @param weight defines the weight to use
  4252. * @return the animationGroup
  4253. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4254. */
  4255. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4256. /**
  4257. * Synchronize and normalize all animatables with a source animatable
  4258. * @param root defines the root animatable to synchronize with
  4259. * @return the animationGroup
  4260. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4261. */
  4262. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4263. /**
  4264. * Goes to a specific frame in this animation group
  4265. * @param frame the frame number to go to
  4266. * @return the animationGroup
  4267. */
  4268. goToFrame(frame: number): AnimationGroup;
  4269. /**
  4270. * Dispose all associated resources
  4271. */
  4272. dispose(): void;
  4273. private _checkAnimationGroupEnded;
  4274. }
  4275. }
  4276. declare module BABYLON {
  4277. /**
  4278. * Class used to override all child animations of a given target
  4279. */
  4280. class AnimationPropertiesOverride {
  4281. /**
  4282. * Gets or sets a value indicating if animation blending must be used
  4283. */
  4284. enableBlending: boolean;
  4285. /**
  4286. * Gets or sets the blending speed to use when enableBlending is true
  4287. */
  4288. blendingSpeed: number;
  4289. /**
  4290. * Gets or sets the default loop mode to use
  4291. */
  4292. loopMode: number;
  4293. }
  4294. }
  4295. declare module BABYLON {
  4296. interface IEasingFunction {
  4297. ease(gradient: number): number;
  4298. }
  4299. class EasingFunction implements IEasingFunction {
  4300. private static _EASINGMODE_EASEIN;
  4301. private static _EASINGMODE_EASEOUT;
  4302. private static _EASINGMODE_EASEINOUT;
  4303. static readonly EASINGMODE_EASEIN: number;
  4304. static readonly EASINGMODE_EASEOUT: number;
  4305. static readonly EASINGMODE_EASEINOUT: number;
  4306. private _easingMode;
  4307. setEasingMode(easingMode: number): void;
  4308. getEasingMode(): number;
  4309. easeInCore(gradient: number): number;
  4310. ease(gradient: number): number;
  4311. }
  4312. class CircleEase extends EasingFunction implements IEasingFunction {
  4313. easeInCore(gradient: number): number;
  4314. }
  4315. class BackEase extends EasingFunction implements IEasingFunction {
  4316. amplitude: number;
  4317. constructor(amplitude?: number);
  4318. easeInCore(gradient: number): number;
  4319. }
  4320. class BounceEase extends EasingFunction implements IEasingFunction {
  4321. bounces: number;
  4322. bounciness: number;
  4323. constructor(bounces?: number, bounciness?: number);
  4324. easeInCore(gradient: number): number;
  4325. }
  4326. class CubicEase extends EasingFunction implements IEasingFunction {
  4327. easeInCore(gradient: number): number;
  4328. }
  4329. class ElasticEase extends EasingFunction implements IEasingFunction {
  4330. oscillations: number;
  4331. springiness: number;
  4332. constructor(oscillations?: number, springiness?: number);
  4333. easeInCore(gradient: number): number;
  4334. }
  4335. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4336. exponent: number;
  4337. constructor(exponent?: number);
  4338. easeInCore(gradient: number): number;
  4339. }
  4340. class PowerEase extends EasingFunction implements IEasingFunction {
  4341. power: number;
  4342. constructor(power?: number);
  4343. easeInCore(gradient: number): number;
  4344. }
  4345. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4346. easeInCore(gradient: number): number;
  4347. }
  4348. class QuarticEase extends EasingFunction implements IEasingFunction {
  4349. easeInCore(gradient: number): number;
  4350. }
  4351. class QuinticEase extends EasingFunction implements IEasingFunction {
  4352. easeInCore(gradient: number): number;
  4353. }
  4354. class SineEase extends EasingFunction implements IEasingFunction {
  4355. easeInCore(gradient: number): number;
  4356. }
  4357. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4358. x1: number;
  4359. y1: number;
  4360. x2: number;
  4361. y2: number;
  4362. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4363. easeInCore(gradient: number): number;
  4364. }
  4365. }
  4366. declare module BABYLON {
  4367. /**
  4368. * Defines a runtime animation
  4369. */
  4370. class RuntimeAnimation {
  4371. private _events;
  4372. /**
  4373. * The current frame of the runtime animation
  4374. */
  4375. private _currentFrame;
  4376. /**
  4377. * The animation used by the runtime animation
  4378. */
  4379. private _animation;
  4380. /**
  4381. * The target of the runtime animation
  4382. */
  4383. private _target;
  4384. /**
  4385. * The initiating animatable
  4386. */
  4387. private _host;
  4388. /**
  4389. * The original value of the runtime animation
  4390. */
  4391. private _originalValue;
  4392. /**
  4393. * The original blend value of the runtime animation
  4394. */
  4395. private _originalBlendValue;
  4396. /**
  4397. * The offsets cache of the runtime animation
  4398. */
  4399. private _offsetsCache;
  4400. /**
  4401. * The high limits cache of the runtime animation
  4402. */
  4403. private _highLimitsCache;
  4404. /**
  4405. * Specifies if the runtime animation has been stopped
  4406. */
  4407. private _stopped;
  4408. /**
  4409. * The blending factor of the runtime animation
  4410. */
  4411. private _blendingFactor;
  4412. /**
  4413. * The BabylonJS scene
  4414. */
  4415. private _scene;
  4416. /**
  4417. * The current value of the runtime animation
  4418. */
  4419. private _currentValue;
  4420. /** @hidden */
  4421. _workValue: any;
  4422. /**
  4423. * The active target of the runtime animation
  4424. */
  4425. private _activeTarget;
  4426. /**
  4427. * The target path of the runtime animation
  4428. */
  4429. private _targetPath;
  4430. /**
  4431. * The weight of the runtime animation
  4432. */
  4433. private _weight;
  4434. /**
  4435. * The ratio offset of the runtime animation
  4436. */
  4437. private _ratioOffset;
  4438. /**
  4439. * The previous delay of the runtime animation
  4440. */
  4441. private _previousDelay;
  4442. /**
  4443. * The previous ratio of the runtime animation
  4444. */
  4445. private _previousRatio;
  4446. /**
  4447. * Gets the current frame of the runtime animation
  4448. */
  4449. readonly currentFrame: number;
  4450. /**
  4451. * Gets the weight of the runtime animation
  4452. */
  4453. readonly weight: number;
  4454. /**
  4455. * Gets the current value of the runtime animation
  4456. */
  4457. readonly currentValue: any;
  4458. /**
  4459. * Gets the target path of the runtime animation
  4460. */
  4461. readonly targetPath: string;
  4462. /**
  4463. * Gets the actual target of the runtime animation
  4464. */
  4465. readonly target: any;
  4466. /**
  4467. * Create a new RuntimeAnimation object
  4468. * @param target defines the target of the animation
  4469. * @param animation defines the source animation object
  4470. * @param scene defines the hosting scene
  4471. * @param host defines the initiating Animatable
  4472. */
  4473. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4474. /**
  4475. * Gets the animation from the runtime animation
  4476. */
  4477. readonly animation: Animation;
  4478. /**
  4479. * Resets the runtime animation to the beginning
  4480. * @param restoreOriginal defines whether to restore the target property to the original value
  4481. */
  4482. reset(restoreOriginal?: boolean): void;
  4483. /**
  4484. * Specifies if the runtime animation is stopped
  4485. * @returns Boolean specifying if the runtime animation is stopped
  4486. */
  4487. isStopped(): boolean;
  4488. /**
  4489. * Disposes of the runtime animation
  4490. */
  4491. dispose(): void;
  4492. /**
  4493. * Interpolates the animation from the current frame
  4494. * @param currentFrame The frame to interpolate the animation to
  4495. * @param repeatCount The number of times that the animation should loop
  4496. * @param loopMode The type of looping mode to use
  4497. * @param offsetValue Animation offset value
  4498. * @param highLimitValue The high limit value
  4499. * @returns The interpolated value
  4500. */
  4501. private _interpolate;
  4502. /**
  4503. * Apply the interpolated value to the target
  4504. * @param currentValue defines the value computed by the animation
  4505. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4506. */
  4507. setValue(currentValue: any, weight?: number): void;
  4508. private _setValue;
  4509. /**
  4510. * Gets the loop pmode of the runtime animation
  4511. * @returns Loop Mode
  4512. */
  4513. private _getCorrectLoopMode;
  4514. /**
  4515. * Move the current animation to a given frame
  4516. * @param frame defines the frame to move to
  4517. */
  4518. goToFrame(frame: number): void;
  4519. /**
  4520. * @hidden Internal use only
  4521. */
  4522. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4523. /**
  4524. * Execute the current animation
  4525. * @param delay defines the delay to add to the current frame
  4526. * @param from defines the lower bound of the animation range
  4527. * @param to defines the upper bound of the animation range
  4528. * @param loop defines if the current animation must loop
  4529. * @param speedRatio defines the current speed ratio
  4530. * @param weight defines the weight of the animation (default is -1 so no weight)
  4531. * @returns a boolean indicating if the animation is running
  4532. */
  4533. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4534. }
  4535. }
  4536. declare module BABYLON {
  4537. /**
  4538. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4540. */
  4541. class Analyser {
  4542. /**
  4543. * Gets or sets the smoothing
  4544. * @ignorenaming
  4545. */
  4546. SMOOTHING: number;
  4547. /**
  4548. * Gets or sets the FFT table size
  4549. * @ignorenaming
  4550. */
  4551. FFT_SIZE: number;
  4552. /**
  4553. * Gets or sets the bar graph amplitude
  4554. * @ignorenaming
  4555. */
  4556. BARGRAPHAMPLITUDE: number;
  4557. /**
  4558. * Gets or sets the position of the debug canvas
  4559. * @ignorenaming
  4560. */
  4561. DEBUGCANVASPOS: {
  4562. x: number;
  4563. y: number;
  4564. };
  4565. /**
  4566. * Gets or sets the debug canvas size
  4567. * @ignorenaming
  4568. */
  4569. DEBUGCANVASSIZE: {
  4570. width: number;
  4571. height: number;
  4572. };
  4573. private _byteFreqs;
  4574. private _byteTime;
  4575. private _floatFreqs;
  4576. private _webAudioAnalyser;
  4577. private _debugCanvas;
  4578. private _debugCanvasContext;
  4579. private _scene;
  4580. private _registerFunc;
  4581. private _audioEngine;
  4582. /**
  4583. * Creates a new analyser
  4584. * @param scene defines hosting scene
  4585. */
  4586. constructor(scene: Scene);
  4587. /**
  4588. * Get the number of data values you will have to play with for the visualization
  4589. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4590. * @returns a number
  4591. */
  4592. getFrequencyBinCount(): number;
  4593. /**
  4594. * Gets the current frequency data as a byte array
  4595. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4596. * @returns a Uint8Array
  4597. */
  4598. getByteFrequencyData(): Uint8Array;
  4599. /**
  4600. * Gets the current waveform as a byte array
  4601. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4602. * @returns a Uint8Array
  4603. */
  4604. getByteTimeDomainData(): Uint8Array;
  4605. /**
  4606. * Gets the current frequency data as a float array
  4607. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4608. * @returns a Float32Array
  4609. */
  4610. getFloatFrequencyData(): Float32Array;
  4611. /**
  4612. * Renders the debug canvas
  4613. */
  4614. drawDebugCanvas(): void;
  4615. /**
  4616. * Stops rendering the debug canvas and removes it
  4617. */
  4618. stopDebugCanvas(): void;
  4619. /**
  4620. * Connects two audio nodes
  4621. * @param inputAudioNode defines first node to connect
  4622. * @param outputAudioNode defines second node to connect
  4623. */
  4624. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4625. /**
  4626. * Releases all associated resources
  4627. */
  4628. dispose(): void;
  4629. }
  4630. }
  4631. declare module BABYLON {
  4632. class AudioEngine {
  4633. private _audioContext;
  4634. private _audioContextInitialized;
  4635. canUseWebAudio: boolean;
  4636. masterGain: GainNode;
  4637. private _connectedAnalyser;
  4638. WarnedWebAudioUnsupported: boolean;
  4639. unlocked: boolean;
  4640. onAudioUnlocked: () => any;
  4641. isMP3supported: boolean;
  4642. isOGGsupported: boolean;
  4643. readonly audioContext: Nullable<AudioContext>;
  4644. constructor();
  4645. private _unlockiOSaudio;
  4646. private _initializeAudioContext;
  4647. dispose(): void;
  4648. getGlobalVolume(): number;
  4649. setGlobalVolume(newVolume: number): void;
  4650. connectToAnalyser(analyser: Analyser): void;
  4651. }
  4652. }
  4653. declare module BABYLON {
  4654. class Sound {
  4655. name: string;
  4656. autoplay: boolean;
  4657. loop: boolean;
  4658. useCustomAttenuation: boolean;
  4659. soundTrackId: number;
  4660. spatialSound: boolean;
  4661. refDistance: number;
  4662. rolloffFactor: number;
  4663. maxDistance: number;
  4664. distanceModel: string;
  4665. private _panningModel;
  4666. onended: () => any;
  4667. /**
  4668. * Observable event when the current playing sound finishes.
  4669. */
  4670. onEndedObservable: Observable<Sound>;
  4671. private _playbackRate;
  4672. private _streaming;
  4673. private _startTime;
  4674. private _startOffset;
  4675. private _position;
  4676. /** @hidden */
  4677. _positionInEmitterSpace: boolean;
  4678. private _localDirection;
  4679. private _volume;
  4680. private _isReadyToPlay;
  4681. isPlaying: boolean;
  4682. isPaused: boolean;
  4683. private _isDirectional;
  4684. private _readyToPlayCallback;
  4685. private _audioBuffer;
  4686. private _soundSource;
  4687. private _streamingSource;
  4688. private _soundPanner;
  4689. private _soundGain;
  4690. private _inputAudioNode;
  4691. private _outputAudioNode;
  4692. private _coneInnerAngle;
  4693. private _coneOuterAngle;
  4694. private _coneOuterGain;
  4695. private _scene;
  4696. private _connectedMesh;
  4697. private _customAttenuationFunction;
  4698. private _registerFunc;
  4699. private _isOutputConnected;
  4700. private _htmlAudioElement;
  4701. private _urlType;
  4702. /**
  4703. * Create a sound and attach it to a scene
  4704. * @param name Name of your sound
  4705. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4706. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4707. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4708. */
  4709. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4710. dispose(): void;
  4711. isReady(): boolean;
  4712. private _soundLoaded;
  4713. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4714. updateOptions(options: any): void;
  4715. private _createSpatialParameters;
  4716. private _updateSpatialParameters;
  4717. switchPanningModelToHRTF(): void;
  4718. switchPanningModelToEqualPower(): void;
  4719. private _switchPanningModel;
  4720. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4721. /**
  4722. * Transform this sound into a directional source
  4723. * @param coneInnerAngle Size of the inner cone in degree
  4724. * @param coneOuterAngle Size of the outer cone in degree
  4725. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4726. */
  4727. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4728. /**
  4729. * Gets or sets the inner angle for the directional cone.
  4730. */
  4731. /**
  4732. * Gets or sets the inner angle for the directional cone.
  4733. */
  4734. directionalConeInnerAngle: number;
  4735. /**
  4736. * Gets or sets the outer angle for the directional cone.
  4737. */
  4738. /**
  4739. * Gets or sets the outer angle for the directional cone.
  4740. */
  4741. directionalConeOuterAngle: number;
  4742. setPosition(newPosition: Vector3): void;
  4743. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4744. private _updateDirection;
  4745. updateDistanceFromListener(): void;
  4746. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4747. /**
  4748. * Play the sound
  4749. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4750. * @param offset (optional) Start the sound setting it at a specific time
  4751. */
  4752. play(time?: number, offset?: number): void;
  4753. private _onended;
  4754. /**
  4755. * Stop the sound
  4756. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4757. */
  4758. stop(time?: number): void;
  4759. pause(): void;
  4760. setVolume(newVolume: number, time?: number): void;
  4761. setPlaybackRate(newPlaybackRate: number): void;
  4762. getVolume(): number;
  4763. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4764. detachFromMesh(): void;
  4765. private _onRegisterAfterWorldMatrixUpdate;
  4766. clone(): Nullable<Sound>;
  4767. getAudioBuffer(): AudioBuffer | null;
  4768. serialize(): any;
  4769. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4770. }
  4771. }
  4772. declare module BABYLON {
  4773. class SoundTrack {
  4774. private _outputAudioNode;
  4775. private _scene;
  4776. id: number;
  4777. soundCollection: Array<Sound>;
  4778. private _isMainTrack;
  4779. private _connectedAnalyser;
  4780. private _options;
  4781. private _isInitialized;
  4782. constructor(scene: Scene, options?: any);
  4783. private _initializeSoundTrackAudioGraph;
  4784. dispose(): void;
  4785. AddSound(sound: Sound): void;
  4786. RemoveSound(sound: Sound): void;
  4787. setVolume(newVolume: number): void;
  4788. switchPanningModelToHRTF(): void;
  4789. switchPanningModelToEqualPower(): void;
  4790. connectToAnalyser(analyser: Analyser): void;
  4791. }
  4792. }
  4793. declare module BABYLON {
  4794. /**
  4795. * Wraps one or more Sound objects and selects one with random weight for playback.
  4796. */
  4797. class WeightedSound {
  4798. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4799. loop: boolean;
  4800. private _coneInnerAngle;
  4801. private _coneOuterAngle;
  4802. private _volume;
  4803. /** A Sound is currently playing. */
  4804. isPlaying: boolean;
  4805. /** A Sound is currently paused. */
  4806. isPaused: boolean;
  4807. private _sounds;
  4808. private _weights;
  4809. private _currentIndex?;
  4810. /**
  4811. * Creates a new WeightedSound from the list of sounds given.
  4812. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4813. * @param sounds Array of Sounds that will be selected from.
  4814. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4815. */
  4816. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4817. /**
  4818. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4819. */
  4820. /**
  4821. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4822. */
  4823. directionalConeInnerAngle: number;
  4824. /**
  4825. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4826. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4827. */
  4828. /**
  4829. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4830. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4831. */
  4832. directionalConeOuterAngle: number;
  4833. /**
  4834. * Playback volume.
  4835. */
  4836. /**
  4837. * Playback volume.
  4838. */
  4839. volume: number;
  4840. private _onended;
  4841. /**
  4842. * Suspend playback
  4843. */
  4844. pause(): void;
  4845. /**
  4846. * Stop playback
  4847. */
  4848. stop(): void;
  4849. /**
  4850. * Start playback.
  4851. * @param startOffset Position the clip head at a specific time in seconds.
  4852. */
  4853. play(startOffset?: number): void;
  4854. }
  4855. }
  4856. declare module BABYLON {
  4857. /**
  4858. * Interface used to define a behavior
  4859. */
  4860. interface Behavior<T> {
  4861. /** gets or sets behavior's name */
  4862. name: string;
  4863. /**
  4864. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4865. */
  4866. init(): void;
  4867. /**
  4868. * Called when the behavior is attached to a target
  4869. * @param target defines the target where the behavior is attached to
  4870. */
  4871. attach(target: T): void;
  4872. /**
  4873. * Called when the behavior is detached from its target
  4874. */
  4875. detach(): void;
  4876. }
  4877. /**
  4878. * Interface implemented by classes supporting behaviors
  4879. */
  4880. interface IBehaviorAware<T> {
  4881. /**
  4882. * Attach a behavior
  4883. * @param behavior defines the behavior to attach
  4884. * @returns the current host
  4885. */
  4886. addBehavior(behavior: Behavior<T>): T;
  4887. /**
  4888. * Remove a behavior from the current object
  4889. * @param behavior defines the behavior to detach
  4890. * @returns the current host
  4891. */
  4892. removeBehavior(behavior: Behavior<T>): T;
  4893. /**
  4894. * Gets a behavior using its name to search
  4895. * @param name defines the name to search
  4896. * @returns the behavior or null if not found
  4897. */
  4898. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4899. }
  4900. }
  4901. declare module BABYLON {
  4902. /**
  4903. * Class used to store bone information
  4904. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4905. */
  4906. class Bone extends Node {
  4907. /**
  4908. * defines the bone name
  4909. */
  4910. name: string;
  4911. private static _tmpVecs;
  4912. private static _tmpQuat;
  4913. private static _tmpMats;
  4914. /**
  4915. * Gets the list of child bones
  4916. */
  4917. children: Bone[];
  4918. /** Gets the animations associated with this bone */
  4919. animations: Animation[];
  4920. /**
  4921. * Gets or sets bone length
  4922. */
  4923. length: number;
  4924. /**
  4925. * @hidden Internal only
  4926. * Set this value to map this bone to a different index in the transform matrices
  4927. * Set this value to -1 to exclude the bone from the transform matrices
  4928. */
  4929. _index: Nullable<number>;
  4930. private _skeleton;
  4931. private _localMatrix;
  4932. private _restPose;
  4933. private _baseMatrix;
  4934. private _absoluteTransform;
  4935. private _invertedAbsoluteTransform;
  4936. private _parent;
  4937. private _scalingDeterminant;
  4938. private _worldTransform;
  4939. private _localScaling;
  4940. private _localRotation;
  4941. private _localPosition;
  4942. private _needToDecompose;
  4943. private _needToCompose;
  4944. /** @hidden */
  4945. /** @hidden */
  4946. _matrix: Matrix;
  4947. /**
  4948. * Create a new bone
  4949. * @param name defines the bone name
  4950. * @param skeleton defines the parent skeleton
  4951. * @param parentBone defines the parent (can be null if the bone is the root)
  4952. * @param localMatrix defines the local matrix
  4953. * @param restPose defines the rest pose matrix
  4954. * @param baseMatrix defines the base matrix
  4955. * @param index defines index of the bone in the hiearchy
  4956. */
  4957. constructor(
  4958. /**
  4959. * defines the bone name
  4960. */
  4961. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4962. /**
  4963. * Gets the parent skeleton
  4964. * @returns a skeleton
  4965. */
  4966. getSkeleton(): Skeleton;
  4967. /**
  4968. * Gets parent bone
  4969. * @returns a bone or null if the bone is the root of the bone hierarchy
  4970. */
  4971. getParent(): Nullable<Bone>;
  4972. /**
  4973. * Sets the parent bone
  4974. * @param parent defines the parent (can be null if the bone is the root)
  4975. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4976. */
  4977. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4978. /**
  4979. * Gets the local matrix
  4980. * @returns a matrix
  4981. */
  4982. getLocalMatrix(): Matrix;
  4983. /**
  4984. * Gets the base matrix (initial matrix which remains unchanged)
  4985. * @returns a matrix
  4986. */
  4987. getBaseMatrix(): Matrix;
  4988. /**
  4989. * Gets the rest pose matrix
  4990. * @returns a matrix
  4991. */
  4992. getRestPose(): Matrix;
  4993. /**
  4994. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4995. */
  4996. getWorldMatrix(): Matrix;
  4997. /**
  4998. * Sets the local matrix to rest pose matrix
  4999. */
  5000. returnToRest(): void;
  5001. /**
  5002. * Gets the inverse of the absolute transform matrix.
  5003. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5004. * @returns a matrix
  5005. */
  5006. getInvertedAbsoluteTransform(): Matrix;
  5007. /**
  5008. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5009. * @returns a matrix
  5010. */
  5011. getAbsoluteTransform(): Matrix;
  5012. /** Gets or sets current position (in local space) */
  5013. position: Vector3;
  5014. /** Gets or sets current rotation (in local space) */
  5015. rotation: Vector3;
  5016. /** Gets or sets current rotation quaternion (in local space) */
  5017. rotationQuaternion: Quaternion;
  5018. /** Gets or sets current scaling (in local space) */
  5019. scaling: Vector3;
  5020. /**
  5021. * Gets the animation properties override
  5022. */
  5023. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5024. private _decompose;
  5025. private _compose;
  5026. /**
  5027. * Update the base and local matrices
  5028. * @param matrix defines the new base or local matrix
  5029. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5030. * @param updateLocalMatrix defines if the local matrix should be updated
  5031. */
  5032. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5033. /** @hidden */
  5034. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5035. /**
  5036. * Flag the bone as dirty (Forcing it to update everything)
  5037. */
  5038. markAsDirty(): void;
  5039. private _markAsDirtyAndCompose;
  5040. private _markAsDirtyAndDecompose;
  5041. /**
  5042. * Copy an animation range from another bone
  5043. * @param source defines the source bone
  5044. * @param rangeName defines the range name to copy
  5045. * @param frameOffset defines the frame offset
  5046. * @param rescaleAsRequired defines if rescaling must be applied if required
  5047. * @param skelDimensionsRatio defines the scaling ratio
  5048. * @returns true if operation was successful
  5049. */
  5050. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5051. /**
  5052. * Translate the bone in local or world space
  5053. * @param vec The amount to translate the bone
  5054. * @param space The space that the translation is in
  5055. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5056. */
  5057. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5058. /**
  5059. * Set the postion of the bone in local or world space
  5060. * @param position The position to set the bone
  5061. * @param space The space that the position is in
  5062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5063. */
  5064. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5065. /**
  5066. * Set the absolute position of the bone (world space)
  5067. * @param position The position to set the bone
  5068. * @param mesh The mesh that this bone is attached to
  5069. */
  5070. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5071. /**
  5072. * Scale the bone on the x, y and z axes (in local space)
  5073. * @param x The amount to scale the bone on the x axis
  5074. * @param y The amount to scale the bone on the y axis
  5075. * @param z The amount to scale the bone on the z axis
  5076. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5077. */
  5078. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5079. /**
  5080. * Set the bone scaling in local space
  5081. * @param scale defines the scaling vector
  5082. */
  5083. setScale(scale: Vector3): void;
  5084. /**
  5085. * Gets the current scaling in local space
  5086. * @returns the current scaling vector
  5087. */
  5088. getScale(): Vector3;
  5089. /**
  5090. * Gets the current scaling in local space and stores it in a target vector
  5091. * @param result defines the target vector
  5092. */
  5093. getScaleToRef(result: Vector3): void;
  5094. /**
  5095. * Set the yaw, pitch, and roll of the bone in local or world space
  5096. * @param yaw The rotation of the bone on the y axis
  5097. * @param pitch The rotation of the bone on the x axis
  5098. * @param roll The rotation of the bone on the z axis
  5099. * @param space The space that the axes of rotation are in
  5100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5101. */
  5102. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5103. /**
  5104. * Add a rotation to the bone on an axis in local or world space
  5105. * @param axis The axis to rotate the bone on
  5106. * @param amount The amount to rotate the bone
  5107. * @param space The space that the axis is in
  5108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5109. */
  5110. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5111. /**
  5112. * Set the rotation of the bone to a particular axis angle in local or world space
  5113. * @param axis The axis to rotate the bone on
  5114. * @param angle The angle that the bone should be rotated to
  5115. * @param space The space that the axis is in
  5116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5117. */
  5118. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5119. /**
  5120. * Set the euler rotation of the bone in local of world space
  5121. * @param rotation The euler rotation that the bone should be set to
  5122. * @param space The space that the rotation is in
  5123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5124. */
  5125. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5126. /**
  5127. * Set the quaternion rotation of the bone in local of world space
  5128. * @param quat The quaternion rotation that the bone should be set to
  5129. * @param space The space that the rotation is in
  5130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5131. */
  5132. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5133. /**
  5134. * Set the rotation matrix of the bone in local of world space
  5135. * @param rotMat The rotation matrix that the bone should be set to
  5136. * @param space The space that the rotation is in
  5137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5138. */
  5139. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5140. private _rotateWithMatrix;
  5141. private _getNegativeRotationToRef;
  5142. /**
  5143. * Get the position of the bone in local or world space
  5144. * @param space The space that the returned position is in
  5145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5146. * @returns The position of the bone
  5147. */
  5148. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5149. /**
  5150. * Copy the position of the bone to a vector3 in local or world space
  5151. * @param space The space that the returned position is in
  5152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5153. * @param result The vector3 to copy the position to
  5154. */
  5155. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5156. /**
  5157. * Get the absolute position of the bone (world space)
  5158. * @param mesh The mesh that this bone is attached to
  5159. * @returns The absolute position of the bone
  5160. */
  5161. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5162. /**
  5163. * Copy the absolute position of the bone (world space) to the result param
  5164. * @param mesh The mesh that this bone is attached to
  5165. * @param result The vector3 to copy the absolute position to
  5166. */
  5167. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5168. /**
  5169. * Compute the absolute transforms of this bone and its children
  5170. */
  5171. computeAbsoluteTransforms(): void;
  5172. /**
  5173. * Get the world direction from an axis that is in the local space of the bone
  5174. * @param localAxis The local direction that is used to compute the world direction
  5175. * @param mesh The mesh that this bone is attached to
  5176. * @returns The world direction
  5177. */
  5178. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5179. /**
  5180. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5181. * @param localAxis The local direction that is used to compute the world direction
  5182. * @param mesh The mesh that this bone is attached to
  5183. * @param result The vector3 that the world direction will be copied to
  5184. */
  5185. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5186. /**
  5187. * Get the euler rotation of the bone in local or world space
  5188. * @param space The space that the rotation should be in
  5189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5190. * @returns The euler rotation
  5191. */
  5192. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5193. /**
  5194. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5195. * @param space The space that the rotation should be in
  5196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5197. * @param result The vector3 that the rotation should be copied to
  5198. */
  5199. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5200. /**
  5201. * Get the quaternion rotation of the bone in either local or world space
  5202. * @param space The space that the rotation should be in
  5203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5204. * @returns The quaternion rotation
  5205. */
  5206. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5207. /**
  5208. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5209. * @param space The space that the rotation should be in
  5210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5211. * @param result The quaternion that the rotation should be copied to
  5212. */
  5213. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5214. /**
  5215. * Get the rotation matrix of the bone in local or world space
  5216. * @param space The space that the rotation should be in
  5217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5218. * @returns The rotation matrix
  5219. */
  5220. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5221. /**
  5222. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5223. * @param space The space that the rotation should be in
  5224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5225. * @param result The quaternion that the rotation should be copied to
  5226. */
  5227. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5228. /**
  5229. * Get the world position of a point that is in the local space of the bone
  5230. * @param position The local position
  5231. * @param mesh The mesh that this bone is attached to
  5232. * @returns The world position
  5233. */
  5234. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5235. /**
  5236. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5237. * @param position The local position
  5238. * @param mesh The mesh that this bone is attached to
  5239. * @param result The vector3 that the world position should be copied to
  5240. */
  5241. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5242. /**
  5243. * Get the local position of a point that is in world space
  5244. * @param position The world position
  5245. * @param mesh The mesh that this bone is attached to
  5246. * @returns The local position
  5247. */
  5248. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5249. /**
  5250. * Get the local position of a point that is in world space and copy it to the result param
  5251. * @param position The world position
  5252. * @param mesh The mesh that this bone is attached to
  5253. * @param result The vector3 that the local position should be copied to
  5254. */
  5255. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5256. }
  5257. }
  5258. declare module BABYLON {
  5259. /**
  5260. * Class used to apply inverse kinematics to bones
  5261. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5262. */
  5263. class BoneIKController {
  5264. private static _tmpVecs;
  5265. private static _tmpQuat;
  5266. private static _tmpMats;
  5267. /**
  5268. * Gets or sets the target mesh
  5269. */
  5270. targetMesh: AbstractMesh;
  5271. /** Gets or sets the mesh used as pole */
  5272. poleTargetMesh: AbstractMesh;
  5273. /**
  5274. * Gets or sets the bone used as pole
  5275. */
  5276. poleTargetBone: Nullable<Bone>;
  5277. /**
  5278. * Gets or sets the target position
  5279. */
  5280. targetPosition: Vector3;
  5281. /**
  5282. * Gets or sets the pole target position
  5283. */
  5284. poleTargetPosition: Vector3;
  5285. /**
  5286. * Gets or sets the pole target local offset
  5287. */
  5288. poleTargetLocalOffset: Vector3;
  5289. /**
  5290. * Gets or sets the pole angle
  5291. */
  5292. poleAngle: number;
  5293. /**
  5294. * Gets or sets the mesh associated with the controller
  5295. */
  5296. mesh: AbstractMesh;
  5297. /**
  5298. * 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)
  5299. */
  5300. slerpAmount: number;
  5301. private _bone1Quat;
  5302. private _bone1Mat;
  5303. private _bone2Ang;
  5304. private _bone1;
  5305. private _bone2;
  5306. private _bone1Length;
  5307. private _bone2Length;
  5308. private _maxAngle;
  5309. private _maxReach;
  5310. private _rightHandedSystem;
  5311. private _bendAxis;
  5312. private _slerping;
  5313. private _adjustRoll;
  5314. /**
  5315. * Gets or sets maximum allowed angle
  5316. */
  5317. maxAngle: number;
  5318. /**
  5319. * Creates a new BoneIKController
  5320. * @param mesh defines the mesh to control
  5321. * @param bone defines the bone to control
  5322. * @param options defines options to set up the controller
  5323. */
  5324. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5325. targetMesh?: AbstractMesh;
  5326. poleTargetMesh?: AbstractMesh;
  5327. poleTargetBone?: Bone;
  5328. poleTargetLocalOffset?: Vector3;
  5329. poleAngle?: number;
  5330. bendAxis?: Vector3;
  5331. maxAngle?: number;
  5332. slerpAmount?: number;
  5333. });
  5334. private _setMaxAngle;
  5335. /**
  5336. * Force the controller to update the bones
  5337. */
  5338. update(): void;
  5339. }
  5340. }
  5341. declare module BABYLON {
  5342. /**
  5343. * Class used to make a bone look toward a point in space
  5344. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5345. */
  5346. class BoneLookController {
  5347. private static _tmpVecs;
  5348. private static _tmpQuat;
  5349. private static _tmpMats;
  5350. /**
  5351. * The target Vector3 that the bone will look at
  5352. */
  5353. target: Vector3;
  5354. /**
  5355. * The mesh that the bone is attached to
  5356. */
  5357. mesh: AbstractMesh;
  5358. /**
  5359. * The bone that will be looking to the target
  5360. */
  5361. bone: Bone;
  5362. /**
  5363. * The up axis of the coordinate system that is used when the bone is rotated
  5364. */
  5365. upAxis: Vector3;
  5366. /**
  5367. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5368. */
  5369. upAxisSpace: Space;
  5370. /**
  5371. * Used to make an adjustment to the yaw of the bone
  5372. */
  5373. adjustYaw: number;
  5374. /**
  5375. * Used to make an adjustment to the pitch of the bone
  5376. */
  5377. adjustPitch: number;
  5378. /**
  5379. * Used to make an adjustment to the roll of the bone
  5380. */
  5381. adjustRoll: number;
  5382. /**
  5383. * 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)
  5384. */
  5385. slerpAmount: number;
  5386. private _minYaw;
  5387. private _maxYaw;
  5388. private _minPitch;
  5389. private _maxPitch;
  5390. private _minYawSin;
  5391. private _minYawCos;
  5392. private _maxYawSin;
  5393. private _maxYawCos;
  5394. private _midYawConstraint;
  5395. private _minPitchTan;
  5396. private _maxPitchTan;
  5397. private _boneQuat;
  5398. private _slerping;
  5399. private _transformYawPitch;
  5400. private _transformYawPitchInv;
  5401. private _firstFrameSkipped;
  5402. private _yawRange;
  5403. private _fowardAxis;
  5404. /**
  5405. * Gets or sets the minimum yaw angle that the bone can look to
  5406. */
  5407. minYaw: number;
  5408. /**
  5409. * Gets or sets the maximum yaw angle that the bone can look to
  5410. */
  5411. maxYaw: number;
  5412. /**
  5413. * Gets or sets the minimum pitch angle that the bone can look to
  5414. */
  5415. minPitch: number;
  5416. /**
  5417. * Gets or sets the maximum pitch angle that the bone can look to
  5418. */
  5419. maxPitch: number;
  5420. /**
  5421. * Create a BoneLookController
  5422. * @param mesh the mesh that the bone belongs to
  5423. * @param bone the bone that will be looking to the target
  5424. * @param target the target Vector3 to look at
  5425. * @param settings optional settings:
  5426. * * maxYaw: the maximum angle the bone will yaw to
  5427. * * minYaw: the minimum angle the bone will yaw to
  5428. * * maxPitch: the maximum angle the bone will pitch to
  5429. * * minPitch: the minimum angle the bone will yaw to
  5430. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5431. * * upAxis: the up axis of the coordinate system
  5432. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5433. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5434. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5435. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5436. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5437. * * adjustRoll: used to make an adjustment to the roll of the bone
  5438. **/
  5439. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5440. maxYaw?: number;
  5441. minYaw?: number;
  5442. maxPitch?: number;
  5443. minPitch?: number;
  5444. slerpAmount?: number;
  5445. upAxis?: Vector3;
  5446. upAxisSpace?: Space;
  5447. yawAxis?: Vector3;
  5448. pitchAxis?: Vector3;
  5449. adjustYaw?: number;
  5450. adjustPitch?: number;
  5451. adjustRoll?: number;
  5452. });
  5453. /**
  5454. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5455. */
  5456. update(): void;
  5457. private _getAngleDiff;
  5458. private _getAngleBetween;
  5459. private _isAngleBetween;
  5460. }
  5461. }
  5462. declare module BABYLON {
  5463. /**
  5464. * Class used to handle skinning animations
  5465. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5466. */
  5467. class Skeleton implements IAnimatable {
  5468. /** defines the skeleton name */
  5469. name: string;
  5470. /** defines the skeleton Id */
  5471. id: string;
  5472. /**
  5473. * Gets the list of child bones
  5474. */
  5475. bones: Bone[];
  5476. /**
  5477. * Gets an estimate of the dimension of the skeleton at rest
  5478. */
  5479. dimensionsAtRest: Vector3;
  5480. /**
  5481. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5482. */
  5483. needInitialSkinMatrix: boolean;
  5484. /**
  5485. * Gets the list of animations attached to this skeleton
  5486. */
  5487. animations: Array<Animation>;
  5488. private _scene;
  5489. private _isDirty;
  5490. private _transformMatrices;
  5491. private _meshesWithPoseMatrix;
  5492. private _animatables;
  5493. private _identity;
  5494. private _synchronizedWithMesh;
  5495. private _ranges;
  5496. private _lastAbsoluteTransformsUpdateId;
  5497. /**
  5498. * Specifies if the skeleton should be serialized
  5499. */
  5500. doNotSerialize: boolean;
  5501. private _animationPropertiesOverride;
  5502. /**
  5503. * Gets or sets the animation properties override
  5504. */
  5505. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5506. /**
  5507. * An observable triggered before computing the skeleton's matrices
  5508. */
  5509. onBeforeComputeObservable: Observable<Skeleton>;
  5510. /**
  5511. * Creates a new skeleton
  5512. * @param name defines the skeleton name
  5513. * @param id defines the skeleton Id
  5514. * @param scene defines the hosting scene
  5515. */
  5516. constructor(
  5517. /** defines the skeleton name */
  5518. name: string,
  5519. /** defines the skeleton Id */
  5520. id: string, scene: Scene);
  5521. /**
  5522. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5523. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5524. * @returns a Float32Array containing matrices data
  5525. */
  5526. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5527. /**
  5528. * Gets the current hosting scene
  5529. * @returns a scene object
  5530. */
  5531. getScene(): Scene;
  5532. /**
  5533. * Gets a string representing the current skeleton data
  5534. * @param fullDetails defines a boolean indicating if we want a verbose version
  5535. * @returns a string representing the current skeleton data
  5536. */
  5537. toString(fullDetails?: boolean): string;
  5538. /**
  5539. * Get bone's index searching by name
  5540. * @param name defines bone's name to search for
  5541. * @return the indice of the bone. Returns -1 if not found
  5542. */
  5543. getBoneIndexByName(name: string): number;
  5544. /**
  5545. * Creater a new animation range
  5546. * @param name defines the name of the range
  5547. * @param from defines the start key
  5548. * @param to defines the end key
  5549. */
  5550. createAnimationRange(name: string, from: number, to: number): void;
  5551. /**
  5552. * Delete a specific animation range
  5553. * @param name defines the name of the range
  5554. * @param deleteFrames defines if frames must be removed as well
  5555. */
  5556. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5557. /**
  5558. * Gets a specific animation range
  5559. * @param name defines the name of the range to look for
  5560. * @returns the requested animation range or null if not found
  5561. */
  5562. getAnimationRange(name: string): Nullable<AnimationRange>;
  5563. /**
  5564. * Gets the list of all animation ranges defined on this skeleton
  5565. * @returns an array
  5566. */
  5567. getAnimationRanges(): Nullable<AnimationRange>[];
  5568. /**
  5569. * Copy animation range from a source skeleton.
  5570. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5571. * @param source defines the source skeleton
  5572. * @param name defines the name of the range to copy
  5573. * @param rescaleAsRequired defines if rescaling must be applied if required
  5574. * @returns true if operation was successful
  5575. */
  5576. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5577. /**
  5578. * Forces the skeleton to go to rest pose
  5579. */
  5580. returnToRest(): void;
  5581. private _getHighestAnimationFrame;
  5582. /**
  5583. * Begin a specific animation range
  5584. * @param name defines the name of the range to start
  5585. * @param loop defines if looping must be turned on (false by default)
  5586. * @param speedRatio defines the speed ratio to apply (1 by default)
  5587. * @param onAnimationEnd defines a callback which will be called when animation will end
  5588. * @returns a new animatable
  5589. */
  5590. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5591. /** @hidden */
  5592. _markAsDirty(): void;
  5593. /** @hidden */
  5594. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5595. /** @hidden */
  5596. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5597. /** @hidden */
  5598. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5599. /**
  5600. * Build all resources required to render a skeleton
  5601. */
  5602. prepare(): void;
  5603. /**
  5604. * Gets the list of animatables currently running for this skeleton
  5605. * @returns an array of animatables
  5606. */
  5607. getAnimatables(): IAnimatable[];
  5608. /**
  5609. * Clone the current skeleton
  5610. * @param name defines the name of the new skeleton
  5611. * @param id defines the id of the enw skeleton
  5612. * @returns the new skeleton
  5613. */
  5614. clone(name: string, id: string): Skeleton;
  5615. /**
  5616. * Enable animation blending for this skeleton
  5617. * @param blendingSpeed defines the blending speed to apply
  5618. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5619. */
  5620. enableBlending(blendingSpeed?: number): void;
  5621. /**
  5622. * Releases all resources associated with the current skeleton
  5623. */
  5624. dispose(): void;
  5625. /**
  5626. * Serialize the skeleton in a JSON object
  5627. * @returns a JSON object
  5628. */
  5629. serialize(): any;
  5630. /**
  5631. * Creates a new skeleton from serialized data
  5632. * @param parsedSkeleton defines the serialized data
  5633. * @param scene defines the hosting scene
  5634. * @returns a new skeleton
  5635. */
  5636. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5637. /**
  5638. * Compute all node absolute transforms
  5639. * @param forceUpdate defines if computation must be done even if cache is up to date
  5640. */
  5641. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5642. /**
  5643. * Gets the root pose matrix
  5644. * @returns a matrix
  5645. */
  5646. getPoseMatrix(): Nullable<Matrix>;
  5647. /**
  5648. * Sorts bones per internal index
  5649. */
  5650. sortBones(): void;
  5651. private _sortBones;
  5652. }
  5653. }
  5654. declare module BABYLON {
  5655. class ArcRotateCamera extends TargetCamera {
  5656. alpha: number;
  5657. beta: number;
  5658. radius: number;
  5659. protected _target: Vector3;
  5660. protected _targetHost: Nullable<AbstractMesh>;
  5661. target: Vector3;
  5662. inertialAlphaOffset: number;
  5663. inertialBetaOffset: number;
  5664. inertialRadiusOffset: number;
  5665. lowerAlphaLimit: Nullable<number>;
  5666. upperAlphaLimit: Nullable<number>;
  5667. lowerBetaLimit: number;
  5668. upperBetaLimit: number;
  5669. lowerRadiusLimit: Nullable<number>;
  5670. upperRadiusLimit: Nullable<number>;
  5671. inertialPanningX: number;
  5672. inertialPanningY: number;
  5673. pinchToPanMaxDistance: number;
  5674. panningDistanceLimit: Nullable<number>;
  5675. panningOriginTarget: Vector3;
  5676. panningInertia: number;
  5677. angularSensibilityX: number;
  5678. angularSensibilityY: number;
  5679. pinchPrecision: number;
  5680. pinchDeltaPercentage: number;
  5681. panningSensibility: number;
  5682. keysUp: number[];
  5683. keysDown: number[];
  5684. keysLeft: number[];
  5685. keysRight: number[];
  5686. wheelPrecision: number;
  5687. wheelDeltaPercentage: number;
  5688. zoomOnFactor: number;
  5689. targetScreenOffset: Vector2;
  5690. allowUpsideDown: boolean;
  5691. _viewMatrix: Matrix;
  5692. _useCtrlForPanning: boolean;
  5693. _panningMouseButton: number;
  5694. inputs: ArcRotateCameraInputsManager;
  5695. _reset: () => void;
  5696. panningAxis: Vector3;
  5697. protected _localDirection: Vector3;
  5698. protected _transformedDirection: Vector3;
  5699. private _bouncingBehavior;
  5700. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5701. useBouncingBehavior: boolean;
  5702. private _framingBehavior;
  5703. readonly framingBehavior: Nullable<FramingBehavior>;
  5704. useFramingBehavior: boolean;
  5705. private _autoRotationBehavior;
  5706. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5707. useAutoRotationBehavior: boolean;
  5708. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5709. onCollide: (collidedMesh: AbstractMesh) => void;
  5710. checkCollisions: boolean;
  5711. collisionRadius: Vector3;
  5712. protected _collider: Collider;
  5713. protected _previousPosition: Vector3;
  5714. protected _collisionVelocity: Vector3;
  5715. protected _newPosition: Vector3;
  5716. protected _previousAlpha: number;
  5717. protected _previousBeta: number;
  5718. protected _previousRadius: number;
  5719. protected _collisionTriggered: boolean;
  5720. protected _targetBoundingCenter: Nullable<Vector3>;
  5721. private _computationVector;
  5722. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5723. _initCache(): void;
  5724. _updateCache(ignoreParentClass?: boolean): void;
  5725. protected _getTargetPosition(): Vector3;
  5726. /**
  5727. * Store current camera state (fov, position, etc..)
  5728. */
  5729. private _storedAlpha;
  5730. private _storedBeta;
  5731. private _storedRadius;
  5732. private _storedTarget;
  5733. storeState(): Camera;
  5734. /**
  5735. * Restored camera state. You must call storeState() first
  5736. */
  5737. _restoreStateValues(): boolean;
  5738. _isSynchronizedViewMatrix(): boolean;
  5739. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5740. detachControl(element: HTMLElement): void;
  5741. _checkInputs(): void;
  5742. protected _checkLimits(): void;
  5743. rebuildAnglesAndRadius(): void;
  5744. setPosition(position: Vector3): void;
  5745. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5746. _getViewMatrix(): Matrix;
  5747. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5748. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5749. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5750. min: Vector3;
  5751. max: Vector3;
  5752. distance: number;
  5753. }, doNotUpdateMaxZ?: boolean): void;
  5754. /**
  5755. * @override
  5756. * Override Camera.createRigCamera
  5757. */
  5758. createRigCamera(name: string, cameraIndex: number): Camera;
  5759. /**
  5760. * @override
  5761. * Override Camera._updateRigCameras
  5762. */
  5763. _updateRigCameras(): void;
  5764. dispose(): void;
  5765. getClassName(): string;
  5766. }
  5767. }
  5768. declare module BABYLON {
  5769. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5770. constructor(camera: ArcRotateCamera);
  5771. addMouseWheel(): ArcRotateCameraInputsManager;
  5772. addPointers(): ArcRotateCameraInputsManager;
  5773. addKeyboard(): ArcRotateCameraInputsManager;
  5774. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5775. }
  5776. }
  5777. declare module BABYLON {
  5778. class Camera extends Node {
  5779. inputs: CameraInputsManager<Camera>;
  5780. private static _PERSPECTIVE_CAMERA;
  5781. private static _ORTHOGRAPHIC_CAMERA;
  5782. private static _FOVMODE_VERTICAL_FIXED;
  5783. private static _FOVMODE_HORIZONTAL_FIXED;
  5784. private static _RIG_MODE_NONE;
  5785. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5786. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5787. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5788. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5789. private static _RIG_MODE_VR;
  5790. private static _RIG_MODE_WEBVR;
  5791. static readonly PERSPECTIVE_CAMERA: number;
  5792. static readonly ORTHOGRAPHIC_CAMERA: number;
  5793. /**
  5794. * This is the default FOV mode for perspective cameras.
  5795. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5796. *
  5797. */
  5798. static readonly FOVMODE_VERTICAL_FIXED: number;
  5799. /**
  5800. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5801. *
  5802. */
  5803. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5804. static readonly RIG_MODE_NONE: number;
  5805. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5806. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5807. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5808. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5809. static readonly RIG_MODE_VR: number;
  5810. static readonly RIG_MODE_WEBVR: number;
  5811. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5812. static UseAlternateWebVRRendering: boolean;
  5813. position: Vector3;
  5814. /**
  5815. * The vector the camera should consider as up.
  5816. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5817. */
  5818. upVector: Vector3;
  5819. orthoLeft: Nullable<number>;
  5820. orthoRight: Nullable<number>;
  5821. orthoBottom: Nullable<number>;
  5822. orthoTop: Nullable<number>;
  5823. /**
  5824. * FOV is set in Radians. (default is 0.8)
  5825. */
  5826. fov: number;
  5827. minZ: number;
  5828. maxZ: number;
  5829. inertia: number;
  5830. mode: number;
  5831. isIntermediate: boolean;
  5832. viewport: Viewport;
  5833. /**
  5834. * Restricts the camera to viewing objects with the same layerMask.
  5835. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5836. */
  5837. layerMask: number;
  5838. /**
  5839. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5840. */
  5841. fovMode: number;
  5842. cameraRigMode: number;
  5843. interaxialDistance: number;
  5844. isStereoscopicSideBySide: boolean;
  5845. _cameraRigParams: any;
  5846. _rigCameras: Camera[];
  5847. _rigPostProcess: Nullable<PostProcess>;
  5848. protected _webvrViewMatrix: Matrix;
  5849. _skipRendering: boolean;
  5850. _alternateCamera: Camera;
  5851. customRenderTargets: RenderTargetTexture[];
  5852. onViewMatrixChangedObservable: Observable<Camera>;
  5853. onProjectionMatrixChangedObservable: Observable<Camera>;
  5854. onAfterCheckInputsObservable: Observable<Camera>;
  5855. onRestoreStateObservable: Observable<Camera>;
  5856. private _computedViewMatrix;
  5857. _projectionMatrix: Matrix;
  5858. private _doNotComputeProjectionMatrix;
  5859. private _worldMatrix;
  5860. _postProcesses: Nullable<PostProcess>[];
  5861. private _transformMatrix;
  5862. _activeMeshes: SmartArray<AbstractMesh>;
  5863. protected _globalPosition: Vector3;
  5864. private _frustumPlanes;
  5865. private _refreshFrustumPlanes;
  5866. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5867. private _storedFov;
  5868. private _stateStored;
  5869. /**
  5870. * Store current camera state (fov, position, etc..)
  5871. */
  5872. storeState(): Camera;
  5873. /**
  5874. * Restores the camera state values if it has been stored. You must call storeState() first
  5875. */
  5876. protected _restoreStateValues(): boolean;
  5877. /**
  5878. * Restored camera state. You must call storeState() first
  5879. */
  5880. restoreState(): boolean;
  5881. getClassName(): string;
  5882. /**
  5883. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5884. */
  5885. toString(fullDetails?: boolean): string;
  5886. readonly globalPosition: Vector3;
  5887. getActiveMeshes(): SmartArray<AbstractMesh>;
  5888. isActiveMesh(mesh: Mesh): boolean;
  5889. /**
  5890. * Is this camera ready to be used/rendered
  5891. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5892. * @return true if the camera is ready
  5893. */
  5894. isReady(completeCheck?: boolean): boolean;
  5895. _initCache(): void;
  5896. _updateCache(ignoreParentClass?: boolean): void;
  5897. _isSynchronized(): boolean;
  5898. _isSynchronizedViewMatrix(): boolean;
  5899. _isSynchronizedProjectionMatrix(): boolean;
  5900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5901. detachControl(element: HTMLElement): void;
  5902. update(): void;
  5903. _checkInputs(): void;
  5904. readonly rigCameras: Camera[];
  5905. readonly rigPostProcess: Nullable<PostProcess>;
  5906. /**
  5907. * Internal, gets the first post proces.
  5908. * @returns the first post process to be run on this camera.
  5909. */
  5910. _getFirstPostProcess(): Nullable<PostProcess>;
  5911. private _cascadePostProcessesToRigCams;
  5912. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5913. detachPostProcess(postProcess: PostProcess): void;
  5914. getWorldMatrix(): Matrix;
  5915. _getViewMatrix(): Matrix;
  5916. getViewMatrix(force?: boolean): Matrix;
  5917. freezeProjectionMatrix(projection?: Matrix): void;
  5918. unfreezeProjectionMatrix(): void;
  5919. getProjectionMatrix(force?: boolean): Matrix;
  5920. /**
  5921. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  5922. * @returns a Matrix
  5923. */
  5924. getTransformationMatrix(): Matrix;
  5925. private updateFrustumPlanes;
  5926. isInFrustum(target: ICullable): boolean;
  5927. isCompletelyInFrustum(target: ICullable): boolean;
  5928. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5929. /**
  5930. * Releases resources associated with this node.
  5931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5933. */
  5934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5935. readonly leftCamera: Nullable<FreeCamera>;
  5936. readonly rightCamera: Nullable<FreeCamera>;
  5937. getLeftTarget(): Nullable<Vector3>;
  5938. getRightTarget(): Nullable<Vector3>;
  5939. setCameraRigMode(mode: number, rigParams: any): void;
  5940. private _getVRProjectionMatrix;
  5941. protected _updateCameraRotationMatrix(): void;
  5942. protected _updateWebVRCameraRotationMatrix(): void;
  5943. /**
  5944. * This function MUST be overwritten by the different WebVR cameras available.
  5945. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5946. */
  5947. protected _getWebVRProjectionMatrix(): Matrix;
  5948. /**
  5949. * This function MUST be overwritten by the different WebVR cameras available.
  5950. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5951. */
  5952. protected _getWebVRViewMatrix(): Matrix;
  5953. setCameraRigParameter(name: string, value: any): void;
  5954. /**
  5955. * needs to be overridden by children so sub has required properties to be copied
  5956. */
  5957. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5958. /**
  5959. * May need to be overridden by children
  5960. */
  5961. _updateRigCameras(): void;
  5962. _setupInputs(): void;
  5963. serialize(): any;
  5964. clone(name: string): Camera;
  5965. getDirection(localAxis: Vector3): Vector3;
  5966. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5967. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5968. computeWorldMatrix(): Matrix;
  5969. static Parse(parsedCamera: any, scene: Scene): Camera;
  5970. }
  5971. }
  5972. declare module BABYLON {
  5973. var CameraInputTypes: {};
  5974. interface ICameraInput<TCamera extends Camera> {
  5975. camera: Nullable<TCamera>;
  5976. getClassName(): string;
  5977. getSimpleName(): string;
  5978. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5979. detachControl: (element: Nullable<HTMLElement>) => void;
  5980. checkInputs?: () => void;
  5981. }
  5982. interface CameraInputsMap<TCamera extends Camera> {
  5983. [name: string]: ICameraInput<TCamera>;
  5984. [idx: number]: ICameraInput<TCamera>;
  5985. }
  5986. class CameraInputsManager<TCamera extends Camera> {
  5987. attached: CameraInputsMap<TCamera>;
  5988. attachedElement: Nullable<HTMLElement>;
  5989. noPreventDefault: boolean;
  5990. camera: TCamera;
  5991. checkInputs: () => void;
  5992. constructor(camera: TCamera);
  5993. /**
  5994. * Add an input method to a camera
  5995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5996. * @param input camera input method
  5997. */
  5998. add(input: ICameraInput<TCamera>): void;
  5999. /**
  6000. * Remove a specific input method from a camera
  6001. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6002. * @param inputToRemove camera input method
  6003. */
  6004. remove(inputToRemove: ICameraInput<TCamera>): void;
  6005. removeByType(inputType: string): void;
  6006. private _addCheckInputs;
  6007. attachInput(input: ICameraInput<TCamera>): void;
  6008. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6009. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6010. rebuildInputCheck(): void;
  6011. /**
  6012. * Remove all attached input methods from a camera
  6013. */
  6014. clear(): void;
  6015. serialize(serializedCamera: any): void;
  6016. parse(parsedCamera: any): void;
  6017. }
  6018. }
  6019. declare module BABYLON {
  6020. /**
  6021. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6022. * being tilted forward or back and left or right.
  6023. */
  6024. class DeviceOrientationCamera extends FreeCamera {
  6025. private _initialQuaternion;
  6026. private _quaternionCache;
  6027. /**
  6028. * Creates a new device orientation camera
  6029. * @param name The name of the camera
  6030. * @param position The start position camera
  6031. * @param scene The scene the camera belongs to
  6032. */
  6033. constructor(name: string, position: Vector3, scene: Scene);
  6034. /**
  6035. * Gets the current instance class name ("DeviceOrientationCamera").
  6036. * This helps avoiding instanceof at run time.
  6037. * @returns the class name
  6038. */
  6039. getClassName(): string;
  6040. /**
  6041. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6042. */
  6043. _checkInputs(): void;
  6044. /**
  6045. * Reset the camera to its default orientation on the specified axis only.
  6046. * @param axis The axis to reset
  6047. */
  6048. resetToCurrentRotation(axis?: Axis): void;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. class FollowCamera extends TargetCamera {
  6053. radius: number;
  6054. rotationOffset: number;
  6055. heightOffset: number;
  6056. cameraAcceleration: number;
  6057. maxCameraSpeed: number;
  6058. lockedTarget: Nullable<AbstractMesh>;
  6059. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6060. private getRadians;
  6061. private follow;
  6062. _checkInputs(): void;
  6063. getClassName(): string;
  6064. }
  6065. class ArcFollowCamera extends TargetCamera {
  6066. alpha: number;
  6067. beta: number;
  6068. radius: number;
  6069. target: Nullable<AbstractMesh>;
  6070. private _cartesianCoordinates;
  6071. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6072. private follow;
  6073. _checkInputs(): void;
  6074. getClassName(): string;
  6075. }
  6076. }
  6077. declare module BABYLON {
  6078. class FreeCamera extends TargetCamera {
  6079. ellipsoid: Vector3;
  6080. ellipsoidOffset: Vector3;
  6081. checkCollisions: boolean;
  6082. applyGravity: boolean;
  6083. inputs: FreeCameraInputsManager;
  6084. /**
  6085. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6086. * Higher values reduce sensitivity.
  6087. */
  6088. /**
  6089. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6090. * Higher values reduce sensitivity.
  6091. */
  6092. angularSensibility: number;
  6093. keysUp: number[];
  6094. keysDown: number[];
  6095. keysLeft: number[];
  6096. keysRight: number[];
  6097. onCollide: (collidedMesh: AbstractMesh) => void;
  6098. private _collider;
  6099. private _needMoveForGravity;
  6100. private _oldPosition;
  6101. private _diffPosition;
  6102. private _newPosition;
  6103. _localDirection: Vector3;
  6104. _transformedDirection: Vector3;
  6105. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6107. detachControl(element: HTMLElement): void;
  6108. private _collisionMask;
  6109. collisionMask: number;
  6110. _collideWithWorld(displacement: Vector3): void;
  6111. private _onCollisionPositionChange;
  6112. _checkInputs(): void;
  6113. _decideIfNeedsToMove(): boolean;
  6114. _updatePosition(): void;
  6115. dispose(): void;
  6116. getClassName(): string;
  6117. }
  6118. }
  6119. declare module BABYLON {
  6120. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6121. constructor(camera: FreeCamera);
  6122. addKeyboard(): FreeCameraInputsManager;
  6123. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6124. addDeviceOrientation(): FreeCameraInputsManager;
  6125. addTouch(): FreeCameraInputsManager;
  6126. addVirtualJoystick(): FreeCameraInputsManager;
  6127. }
  6128. }
  6129. declare module BABYLON {
  6130. class GamepadCamera extends UniversalCamera {
  6131. gamepadAngularSensibility: number;
  6132. gamepadMoveSensibility: number;
  6133. constructor(name: string, position: Vector3, scene: Scene);
  6134. getClassName(): string;
  6135. }
  6136. }
  6137. declare module BABYLON {
  6138. class TargetCamera extends Camera {
  6139. cameraDirection: Vector3;
  6140. cameraRotation: Vector2;
  6141. rotation: Vector3;
  6142. rotationQuaternion: Quaternion;
  6143. speed: number;
  6144. noRotationConstraint: boolean;
  6145. lockedTarget: any;
  6146. _currentTarget: Vector3;
  6147. _viewMatrix: Matrix;
  6148. _camMatrix: Matrix;
  6149. _cameraTransformMatrix: Matrix;
  6150. _cameraRotationMatrix: Matrix;
  6151. private _rigCamTransformMatrix;
  6152. _referencePoint: Vector3;
  6153. private _currentUpVector;
  6154. _transformedReferencePoint: Vector3;
  6155. protected _globalCurrentTarget: Vector3;
  6156. protected _globalCurrentUpVector: Vector3;
  6157. _reset: () => void;
  6158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6159. getFrontPosition(distance: number): Vector3;
  6160. _getLockedTargetPosition(): Nullable<Vector3>;
  6161. /**
  6162. * Store current camera state (fov, position, etc..)
  6163. */
  6164. private _storedPosition;
  6165. private _storedRotation;
  6166. private _storedRotationQuaternion;
  6167. storeState(): Camera;
  6168. /**
  6169. * Restored camera state. You must call storeState() first
  6170. * @returns whether it was successful or not
  6171. */
  6172. _restoreStateValues(): boolean;
  6173. _initCache(): void;
  6174. _updateCache(ignoreParentClass?: boolean): void;
  6175. _isSynchronizedViewMatrix(): boolean;
  6176. _computeLocalCameraSpeed(): number;
  6177. setTarget(target: Vector3): void;
  6178. /**
  6179. * Return the current target position of the camera. This value is expressed in local space.
  6180. */
  6181. getTarget(): Vector3;
  6182. _decideIfNeedsToMove(): boolean;
  6183. _updatePosition(): void;
  6184. _checkInputs(): void;
  6185. protected _updateCameraRotationMatrix(): void;
  6186. _getViewMatrix(): Matrix;
  6187. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6188. /**
  6189. * @override
  6190. * Override Camera.createRigCamera
  6191. */
  6192. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6193. /**
  6194. * @override
  6195. * Override Camera._updateRigCameras
  6196. */
  6197. _updateRigCameras(): void;
  6198. private _getRigCamPosition;
  6199. getClassName(): string;
  6200. }
  6201. }
  6202. declare module BABYLON {
  6203. class TouchCamera extends FreeCamera {
  6204. touchAngularSensibility: number;
  6205. touchMoveSensibility: number;
  6206. constructor(name: string, position: Vector3, scene: Scene);
  6207. getClassName(): string;
  6208. _setupInputs(): void;
  6209. }
  6210. }
  6211. declare module BABYLON {
  6212. class UniversalCamera extends TouchCamera {
  6213. gamepadAngularSensibility: number;
  6214. gamepadMoveSensibility: number;
  6215. constructor(name: string, position: Vector3, scene: Scene);
  6216. getClassName(): string;
  6217. }
  6218. }
  6219. declare module BABYLON {
  6220. class VirtualJoysticksCamera extends FreeCamera {
  6221. constructor(name: string, position: Vector3, scene: Scene);
  6222. getClassName(): string;
  6223. }
  6224. }
  6225. interface VRDisplay extends EventTarget {
  6226. /**
  6227. * Dictionary of capabilities describing the VRDisplay.
  6228. */
  6229. readonly capabilities: VRDisplayCapabilities;
  6230. /**
  6231. * z-depth defining the far plane of the eye view frustum
  6232. * enables mapping of values in the render target depth
  6233. * attachment to scene coordinates. Initially set to 10000.0.
  6234. */
  6235. depthFar: number;
  6236. /**
  6237. * z-depth defining the near plane of the eye view frustum
  6238. * enables mapping of values in the render target depth
  6239. * attachment to scene coordinates. Initially set to 0.01.
  6240. */
  6241. depthNear: number;
  6242. /**
  6243. * An identifier for this distinct VRDisplay. Used as an
  6244. * association point in the Gamepad API.
  6245. */
  6246. readonly displayId: number;
  6247. /**
  6248. * A display name, a user-readable name identifying it.
  6249. */
  6250. readonly displayName: string;
  6251. readonly isConnected: boolean;
  6252. readonly isPresenting: boolean;
  6253. /**
  6254. * If this VRDisplay supports room-scale experiences, the optional
  6255. * stage attribute contains details on the room-scale parameters.
  6256. */
  6257. readonly stageParameters: VRStageParameters | null;
  6258. /**
  6259. * Passing the value returned by `requestAnimationFrame` to
  6260. * `cancelAnimationFrame` will unregister the callback.
  6261. */
  6262. cancelAnimationFrame(handle: number): void;
  6263. /**
  6264. * Stops presenting to the VRDisplay.
  6265. */
  6266. exitPresent(): Promise<void>;
  6267. getEyeParameters(whichEye: string): VREyeParameters;
  6268. /**
  6269. * Populates the passed VRFrameData with the information required to render
  6270. * the current frame.
  6271. */
  6272. getFrameData(frameData: VRFrameData): boolean;
  6273. /**
  6274. * Get the layers currently being presented.
  6275. */
  6276. getLayers(): VRLayer[];
  6277. /**
  6278. * Return a VRPose containing the future predicted pose of the VRDisplay
  6279. * when the current frame will be presented. The value returned will not
  6280. * change until JavaScript has returned control to the browser.
  6281. *
  6282. * The VRPose will contain the position, orientation, velocity,
  6283. * and acceleration of each of these properties.
  6284. */
  6285. getPose(): VRPose;
  6286. /**
  6287. * Return the current instantaneous pose of the VRDisplay, with no
  6288. * prediction applied.
  6289. */
  6290. getImmediatePose(): VRPose;
  6291. /**
  6292. * The callback passed to `requestAnimationFrame` will be called
  6293. * any time a new frame should be rendered. When the VRDisplay is
  6294. * presenting the callback will be called at the native refresh
  6295. * rate of the HMD. When not presenting this function acts
  6296. * identically to how window.requestAnimationFrame acts. Content should
  6297. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6298. * asynchronously from other displays and at differing refresh rates.
  6299. */
  6300. requestAnimationFrame(callback: FrameRequestCallback): number;
  6301. /**
  6302. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6303. * Repeat calls while already presenting will update the VRLayers being displayed.
  6304. */
  6305. requestPresent(layers: VRLayer[]): Promise<void>;
  6306. /**
  6307. * Reset the pose for this display, treating its current position and
  6308. * orientation as the "origin/zero" values. VRPose.position,
  6309. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6310. * updated when calling resetPose(). This should be called in only
  6311. * sitting-space experiences.
  6312. */
  6313. resetPose(): void;
  6314. /**
  6315. * The VRLayer provided to the VRDisplay will be captured and presented
  6316. * in the HMD. Calling this function has the same effect on the source
  6317. * canvas as any other operation that uses its source image, and canvases
  6318. * created without preserveDrawingBuffer set to true will be cleared.
  6319. */
  6320. submitFrame(pose?: VRPose): void;
  6321. }
  6322. declare var VRDisplay: {
  6323. prototype: VRDisplay;
  6324. new (): VRDisplay;
  6325. };
  6326. interface VRLayer {
  6327. leftBounds?: number[] | null;
  6328. rightBounds?: number[] | null;
  6329. source?: HTMLCanvasElement | null;
  6330. }
  6331. interface VRDisplayCapabilities {
  6332. readonly canPresent: boolean;
  6333. readonly hasExternalDisplay: boolean;
  6334. readonly hasOrientation: boolean;
  6335. readonly hasPosition: boolean;
  6336. readonly maxLayers: number;
  6337. }
  6338. interface VREyeParameters {
  6339. /** @deprecated */
  6340. readonly fieldOfView: VRFieldOfView;
  6341. readonly offset: Float32Array;
  6342. readonly renderHeight: number;
  6343. readonly renderWidth: number;
  6344. }
  6345. interface VRFieldOfView {
  6346. readonly downDegrees: number;
  6347. readonly leftDegrees: number;
  6348. readonly rightDegrees: number;
  6349. readonly upDegrees: number;
  6350. }
  6351. interface VRFrameData {
  6352. readonly leftProjectionMatrix: Float32Array;
  6353. readonly leftViewMatrix: Float32Array;
  6354. readonly pose: VRPose;
  6355. readonly rightProjectionMatrix: Float32Array;
  6356. readonly rightViewMatrix: Float32Array;
  6357. readonly timestamp: number;
  6358. }
  6359. interface VRPose {
  6360. readonly angularAcceleration: Float32Array | null;
  6361. readonly angularVelocity: Float32Array | null;
  6362. readonly linearAcceleration: Float32Array | null;
  6363. readonly linearVelocity: Float32Array | null;
  6364. readonly orientation: Float32Array | null;
  6365. readonly position: Float32Array | null;
  6366. readonly timestamp: number;
  6367. }
  6368. interface VRStageParameters {
  6369. sittingToStandingTransform?: Float32Array;
  6370. sizeX?: number;
  6371. sizeY?: number;
  6372. }
  6373. interface Navigator {
  6374. getVRDisplays(): Promise<VRDisplay[]>;
  6375. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6376. }
  6377. interface Window {
  6378. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6379. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6380. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6381. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6382. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6383. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6384. }
  6385. interface Gamepad {
  6386. readonly displayId: number;
  6387. }
  6388. declare module BABYLON {
  6389. class BoundingBox implements ICullable {
  6390. vectors: Vector3[];
  6391. center: Vector3;
  6392. centerWorld: Vector3;
  6393. extendSize: Vector3;
  6394. extendSizeWorld: Vector3;
  6395. directions: Vector3[];
  6396. vectorsWorld: Vector3[];
  6397. minimumWorld: Vector3;
  6398. maximumWorld: Vector3;
  6399. minimum: Vector3;
  6400. maximum: Vector3;
  6401. private _worldMatrix;
  6402. /**
  6403. * Creates a new bounding box
  6404. * @param min defines the minimum vector (in local space)
  6405. * @param max defines the maximum vector (in local space)
  6406. */
  6407. constructor(min: Vector3, max: Vector3);
  6408. /**
  6409. * Recreates the entire bounding box from scratch
  6410. * @param min defines the new minimum vector (in local space)
  6411. * @param max defines the new maximum vector (in local space)
  6412. */
  6413. reConstruct(min: Vector3, max: Vector3): void;
  6414. /**
  6415. * Scale the current bounding box by applying a scale factor
  6416. * @param factor defines the scale factor to apply
  6417. * @returns the current bounding box
  6418. */
  6419. scale(factor: number): BoundingBox;
  6420. getWorldMatrix(): Matrix;
  6421. setWorldMatrix(matrix: Matrix): BoundingBox;
  6422. _update(world: Matrix): void;
  6423. isInFrustum(frustumPlanes: Plane[]): boolean;
  6424. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6425. intersectsPoint(point: Vector3): boolean;
  6426. intersectsSphere(sphere: BoundingSphere): boolean;
  6427. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6428. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6429. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6430. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6431. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6432. }
  6433. }
  6434. declare module BABYLON {
  6435. interface ICullable {
  6436. isInFrustum(frustumPlanes: Plane[]): boolean;
  6437. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6438. }
  6439. class BoundingInfo implements ICullable {
  6440. minimum: Vector3;
  6441. maximum: Vector3;
  6442. boundingBox: BoundingBox;
  6443. boundingSphere: BoundingSphere;
  6444. private _isLocked;
  6445. constructor(minimum: Vector3, maximum: Vector3);
  6446. isLocked: boolean;
  6447. update(world: Matrix): void;
  6448. /**
  6449. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6450. * @param center New center of the bounding info
  6451. * @param extend New extend of the bounding info
  6452. */
  6453. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6454. /**
  6455. * Scale the current bounding info by applying a scale factor
  6456. * @param factor defines the scale factor to apply
  6457. * @returns the current bounding info
  6458. */
  6459. scale(factor: number): BoundingInfo;
  6460. isInFrustum(frustumPlanes: Plane[]): boolean;
  6461. /**
  6462. * Gets the world distance between the min and max points of the bounding box
  6463. */
  6464. readonly diagonalLength: number;
  6465. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6466. _checkCollision(collider: Collider): boolean;
  6467. intersectsPoint(point: Vector3): boolean;
  6468. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6469. }
  6470. }
  6471. declare module BABYLON {
  6472. class BoundingSphere {
  6473. center: Vector3;
  6474. radius: number;
  6475. centerWorld: Vector3;
  6476. radiusWorld: number;
  6477. minimum: Vector3;
  6478. maximum: Vector3;
  6479. private _tempRadiusVector;
  6480. /**
  6481. * Creates a new bounding sphere
  6482. * @param min defines the minimum vector (in local space)
  6483. * @param max defines the maximum vector (in local space)
  6484. */
  6485. constructor(min: Vector3, max: Vector3);
  6486. /**
  6487. * Recreates the entire bounding sphere from scratch
  6488. * @param min defines the new minimum vector (in local space)
  6489. * @param max defines the new maximum vector (in local space)
  6490. */
  6491. reConstruct(min: Vector3, max: Vector3): void;
  6492. /**
  6493. * Scale the current bounding sphere by applying a scale factor
  6494. * @param factor defines the scale factor to apply
  6495. * @returns the current bounding box
  6496. */
  6497. scale(factor: number): BoundingSphere;
  6498. _update(world: Matrix): void;
  6499. isInFrustum(frustumPlanes: Plane[]): boolean;
  6500. intersectsPoint(point: Vector3): boolean;
  6501. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6502. }
  6503. }
  6504. declare module BABYLON {
  6505. class Ray {
  6506. origin: Vector3;
  6507. direction: Vector3;
  6508. length: number;
  6509. private _edge1;
  6510. private _edge2;
  6511. private _pvec;
  6512. private _tvec;
  6513. private _qvec;
  6514. private _tmpRay;
  6515. constructor(origin: Vector3, direction: Vector3, length?: number);
  6516. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6517. intersectsBox(box: BoundingBox): boolean;
  6518. intersectsSphere(sphere: BoundingSphere): boolean;
  6519. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6520. intersectsPlane(plane: Plane): Nullable<number>;
  6521. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6522. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6523. private _comparePickingInfo;
  6524. private static smallnum;
  6525. private static rayl;
  6526. /**
  6527. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6528. * @param sega the first point of the segment to test the intersection against
  6529. * @param segb the second point of the segment to test the intersection against
  6530. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6531. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6532. */
  6533. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6534. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6535. static Zero(): Ray;
  6536. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6537. /**
  6538. * 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
  6539. * transformed to the given world matrix.
  6540. * @param origin The origin point
  6541. * @param end The end point
  6542. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6543. */
  6544. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6545. static Transform(ray: Ray, matrix: Matrix): Ray;
  6546. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6547. }
  6548. }
  6549. /**
  6550. * Module Debug contains the (visual) components to debug a scene correctly
  6551. */
  6552. declare module BABYLON.Debug {
  6553. /**
  6554. * The Axes viewer will show 3 axes in a specific point in space
  6555. */
  6556. class AxesViewer {
  6557. private _xline;
  6558. private _yline;
  6559. private _zline;
  6560. private _xmesh;
  6561. private _ymesh;
  6562. private _zmesh;
  6563. /**
  6564. * Gets the hosting scene
  6565. */
  6566. scene: Nullable<Scene>;
  6567. /**
  6568. * Gets or sets a number used to scale line length
  6569. */
  6570. scaleLines: number;
  6571. /**
  6572. * Creates a new AxesViewer
  6573. * @param scene defines the hosting scene
  6574. * @param scaleLines defines a number used to scale line length (1 by default)
  6575. */
  6576. constructor(scene: Scene, scaleLines?: number);
  6577. /**
  6578. * Force the viewer to update
  6579. * @param position defines the position of the viewer
  6580. * @param xaxis defines the x axis of the viewer
  6581. * @param yaxis defines the y axis of the viewer
  6582. * @param zaxis defines the z axis of the viewer
  6583. */
  6584. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6585. /** Releases resources */
  6586. dispose(): void;
  6587. }
  6588. }
  6589. declare module BABYLON.Debug {
  6590. /**
  6591. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6592. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6593. */
  6594. class BoneAxesViewer extends AxesViewer {
  6595. /**
  6596. * Gets or sets the target mesh where to display the axes viewer
  6597. */
  6598. mesh: Nullable<Mesh>;
  6599. /**
  6600. * Gets or sets the target bone where to display the axes viewer
  6601. */
  6602. bone: Nullable<Bone>;
  6603. /** Gets current position */
  6604. pos: Vector3;
  6605. /** Gets direction of X axis */
  6606. xaxis: Vector3;
  6607. /** Gets direction of Y axis */
  6608. yaxis: Vector3;
  6609. /** Gets direction of Z axis */
  6610. zaxis: Vector3;
  6611. /**
  6612. * Creates a new BoneAxesViewer
  6613. * @param scene defines the hosting scene
  6614. * @param bone defines the target bone
  6615. * @param mesh defines the target mesh
  6616. * @param scaleLines defines a scaling factor for line length (1 by default)
  6617. */
  6618. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6619. /**
  6620. * Force the viewer to update
  6621. */
  6622. update(): void;
  6623. /** Releases resources */
  6624. dispose(): void;
  6625. }
  6626. }
  6627. declare module BABYLON {
  6628. class DebugLayer {
  6629. private _scene;
  6630. static InspectorURL: string;
  6631. private _inspector;
  6632. private BJSINSPECTOR;
  6633. onPropertyChangedObservable: Observable<{
  6634. object: any;
  6635. property: string;
  6636. value: any;
  6637. initialValue: any;
  6638. }>;
  6639. constructor(scene: Scene);
  6640. /** Creates the inspector window. */
  6641. private _createInspector;
  6642. isVisible(): boolean;
  6643. hide(): void;
  6644. /**
  6645. *
  6646. * Launch the debugLayer.
  6647. *
  6648. * initialTab:
  6649. * | Value | Tab Name |
  6650. * | --- | --- |
  6651. * | 0 | Scene |
  6652. * | 1 | Console |
  6653. * | 2 | Stats |
  6654. * | 3 | Textures |
  6655. * | 4 | Mesh |
  6656. * | 5 | Light |
  6657. * | 6 | Material |
  6658. * | 7 | GLTF |
  6659. * | 8 | GUI |
  6660. * | 9 | Physics |
  6661. * | 10 | Camera |
  6662. * | 11 | Audio |
  6663. *
  6664. */
  6665. show(config?: {
  6666. popup?: boolean;
  6667. initialTab?: number;
  6668. parentElement?: HTMLElement;
  6669. newColors?: {
  6670. backgroundColor?: string;
  6671. backgroundColorLighter?: string;
  6672. backgroundColorLighter2?: string;
  6673. backgroundColorLighter3?: string;
  6674. color?: string;
  6675. colorTop?: string;
  6676. colorBot?: string;
  6677. };
  6678. }): void;
  6679. /**
  6680. * Gets the active tab
  6681. * @return the index of the active tab or -1 if the inspector is hidden
  6682. */
  6683. getActiveTab(): number;
  6684. }
  6685. }
  6686. declare module BABYLON.Debug {
  6687. /**
  6688. * Used to show the physics impostor around the specific mesh
  6689. */
  6690. class PhysicsViewer {
  6691. /** @hidden */
  6692. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6693. /** @hidden */
  6694. protected _meshes: Array<Nullable<AbstractMesh>>;
  6695. /** @hidden */
  6696. protected _scene: Nullable<Scene>;
  6697. /** @hidden */
  6698. protected _numMeshes: number;
  6699. /** @hidden */
  6700. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6701. private _renderFunction;
  6702. private _debugBoxMesh;
  6703. private _debugSphereMesh;
  6704. private _debugMaterial;
  6705. /**
  6706. * Creates a new PhysicsViewer
  6707. * @param scene defines the hosting scene
  6708. */
  6709. constructor(scene: Scene);
  6710. /** @hidden */
  6711. protected _updateDebugMeshes(): void;
  6712. /**
  6713. * Renders a specified physic impostor
  6714. * @param impostor defines the impostor to render
  6715. */
  6716. showImpostor(impostor: PhysicsImpostor): void;
  6717. /**
  6718. * Hides a specified physic impostor
  6719. * @param impostor defines the impostor to hide
  6720. */
  6721. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6722. private _getDebugMaterial;
  6723. private _getDebugBoxMesh;
  6724. private _getDebugSphereMesh;
  6725. private _getDebugMesh;
  6726. /** Releases all resources */
  6727. dispose(): void;
  6728. }
  6729. }
  6730. declare module BABYLON {
  6731. class RayHelper {
  6732. ray: Nullable<Ray>;
  6733. private _renderPoints;
  6734. private _renderLine;
  6735. private _renderFunction;
  6736. private _scene;
  6737. private _updateToMeshFunction;
  6738. private _attachedToMesh;
  6739. private _meshSpaceDirection;
  6740. private _meshSpaceOrigin;
  6741. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6742. constructor(ray: Ray);
  6743. show(scene: Scene, color?: Color3): void;
  6744. hide(): void;
  6745. private _render;
  6746. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6747. detachFromMesh(): void;
  6748. private _updateToMesh;
  6749. dispose(): void;
  6750. }
  6751. }
  6752. declare module BABYLON.Debug {
  6753. /**
  6754. * Class used to render a debug view of a given skeleton
  6755. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  6756. */
  6757. class SkeletonViewer {
  6758. /** defines the skeleton to render */
  6759. skeleton: Skeleton;
  6760. /** defines the mesh attached to the skeleton */
  6761. mesh: AbstractMesh;
  6762. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6763. autoUpdateBonesMatrices: boolean;
  6764. /** defines the rendering group id to use with the viewer */
  6765. renderingGroupId: number;
  6766. /** Gets or sets the color used to render the skeleton */
  6767. color: Color3;
  6768. private _scene;
  6769. private _debugLines;
  6770. private _debugMesh;
  6771. private _isEnabled;
  6772. private _renderFunction;
  6773. /**
  6774. * Creates a new SkeletonViewer
  6775. * @param skeleton defines the skeleton to render
  6776. * @param mesh defines the mesh attached to the skeleton
  6777. * @param scene defines the hosting scene
  6778. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  6779. * @param renderingGroupId defines the rendering group id to use with the viewer
  6780. */
  6781. constructor(
  6782. /** defines the skeleton to render */
  6783. skeleton: Skeleton,
  6784. /** defines the mesh attached to the skeleton */
  6785. mesh: AbstractMesh, scene: Scene,
  6786. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6787. autoUpdateBonesMatrices?: boolean,
  6788. /** defines the rendering group id to use with the viewer */
  6789. renderingGroupId?: number);
  6790. /** Gets or sets a boolean indicating if the viewer is enabled */
  6791. isEnabled: boolean;
  6792. private _getBonePosition;
  6793. private _getLinesForBonesWithLength;
  6794. private _getLinesForBonesNoLength;
  6795. /** Update the viewer to sync with current skeleton state */
  6796. update(): void;
  6797. /** Release associated resources */
  6798. dispose(): void;
  6799. }
  6800. }
  6801. declare module BABYLON {
  6802. class Collider {
  6803. /** Define if a collision was found */
  6804. collisionFound: boolean;
  6805. /**
  6806. * Define last intersection point in local space
  6807. */
  6808. intersectionPoint: Vector3;
  6809. /**
  6810. * Define last collided mesh
  6811. */
  6812. collidedMesh: Nullable<AbstractMesh>;
  6813. private _collisionPoint;
  6814. private _planeIntersectionPoint;
  6815. private _tempVector;
  6816. private _tempVector2;
  6817. private _tempVector3;
  6818. private _tempVector4;
  6819. private _edge;
  6820. private _baseToVertex;
  6821. private _destinationPoint;
  6822. private _slidePlaneNormal;
  6823. private _displacementVector;
  6824. _radius: Vector3;
  6825. _retry: number;
  6826. private _velocity;
  6827. private _basePoint;
  6828. private _epsilon;
  6829. _velocityWorldLength: number;
  6830. _basePointWorld: Vector3;
  6831. private _velocityWorld;
  6832. private _normalizedVelocity;
  6833. _initialVelocity: Vector3;
  6834. _initialPosition: Vector3;
  6835. private _nearestDistance;
  6836. private _collisionMask;
  6837. collisionMask: number;
  6838. /**
  6839. * Gets the plane normal used to compute the sliding response (in local space)
  6840. */
  6841. readonly slidePlaneNormal: Vector3;
  6842. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6843. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6844. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6845. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6846. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6847. _getResponse(pos: Vector3, vel: Vector3): void;
  6848. }
  6849. }
  6850. declare module BABYLON {
  6851. var CollisionWorker: string;
  6852. interface ICollisionCoordinator {
  6853. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6854. init(scene: Scene): void;
  6855. destroy(): void;
  6856. onMeshAdded(mesh: AbstractMesh): void;
  6857. onMeshUpdated(mesh: AbstractMesh): void;
  6858. onMeshRemoved(mesh: AbstractMesh): void;
  6859. onGeometryAdded(geometry: Geometry): void;
  6860. onGeometryUpdated(geometry: Geometry): void;
  6861. onGeometryDeleted(geometry: Geometry): void;
  6862. }
  6863. interface SerializedMesh {
  6864. id: string;
  6865. name: string;
  6866. uniqueId: number;
  6867. geometryId: Nullable<string>;
  6868. sphereCenter: Array<number>;
  6869. sphereRadius: number;
  6870. boxMinimum: Array<number>;
  6871. boxMaximum: Array<number>;
  6872. worldMatrixFromCache: any;
  6873. subMeshes: Array<SerializedSubMesh>;
  6874. checkCollisions: boolean;
  6875. }
  6876. interface SerializedSubMesh {
  6877. position: number;
  6878. verticesStart: number;
  6879. verticesCount: number;
  6880. indexStart: number;
  6881. indexCount: number;
  6882. hasMaterial: boolean;
  6883. sphereCenter: Array<number>;
  6884. sphereRadius: number;
  6885. boxMinimum: Array<number>;
  6886. boxMaximum: Array<number>;
  6887. }
  6888. /**
  6889. * Interface describing the value associated with a geometry
  6890. */
  6891. interface SerializedGeometry {
  6892. /**
  6893. * Defines the unique ID of the geometry
  6894. */
  6895. id: string;
  6896. /**
  6897. * Defines the array containing the positions
  6898. */
  6899. positions: Float32Array;
  6900. /**
  6901. * Defines the array containing the indices
  6902. */
  6903. indices: Uint32Array;
  6904. /**
  6905. * Defines the array containing the normals
  6906. */
  6907. normals: Float32Array;
  6908. }
  6909. interface BabylonMessage {
  6910. taskType: WorkerTaskType;
  6911. payload: InitPayload | CollidePayload | UpdatePayload;
  6912. }
  6913. interface SerializedColliderToWorker {
  6914. position: Array<number>;
  6915. velocity: Array<number>;
  6916. radius: Array<number>;
  6917. }
  6918. /** Defines supported task for worker process */
  6919. enum WorkerTaskType {
  6920. /** Initialization */
  6921. INIT = 0,
  6922. /** Update of geometry */
  6923. UPDATE = 1,
  6924. /** Evaluate collision */
  6925. COLLIDE = 2
  6926. }
  6927. interface WorkerReply {
  6928. error: WorkerReplyType;
  6929. taskType: WorkerTaskType;
  6930. payload?: any;
  6931. }
  6932. interface CollisionReplyPayload {
  6933. newPosition: Array<number>;
  6934. collisionId: number;
  6935. collidedMeshUniqueId: number;
  6936. }
  6937. interface InitPayload {
  6938. }
  6939. interface CollidePayload {
  6940. collisionId: number;
  6941. collider: SerializedColliderToWorker;
  6942. maximumRetry: number;
  6943. excludedMeshUniqueId: Nullable<number>;
  6944. }
  6945. interface UpdatePayload {
  6946. updatedMeshes: {
  6947. [n: number]: SerializedMesh;
  6948. };
  6949. updatedGeometries: {
  6950. [s: string]: SerializedGeometry;
  6951. };
  6952. removedMeshes: Array<number>;
  6953. removedGeometries: Array<string>;
  6954. }
  6955. /** Defines kind of replies returned by worker */
  6956. enum WorkerReplyType {
  6957. /** Success */
  6958. SUCCESS = 0,
  6959. /** Unkown error */
  6960. UNKNOWN_ERROR = 1
  6961. }
  6962. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6963. private _scene;
  6964. private _scaledPosition;
  6965. private _scaledVelocity;
  6966. private _collisionsCallbackArray;
  6967. private _init;
  6968. private _runningUpdated;
  6969. private _worker;
  6970. private _addUpdateMeshesList;
  6971. private _addUpdateGeometriesList;
  6972. private _toRemoveMeshesArray;
  6973. private _toRemoveGeometryArray;
  6974. constructor();
  6975. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6976. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6977. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6978. init(scene: Scene): void;
  6979. destroy(): void;
  6980. onMeshAdded(mesh: AbstractMesh): void;
  6981. onMeshUpdated: (transformNode: TransformNode) => void;
  6982. onMeshRemoved(mesh: AbstractMesh): void;
  6983. onGeometryAdded(geometry: Geometry): void;
  6984. onGeometryUpdated: (geometry: Geometry) => void;
  6985. onGeometryDeleted(geometry: Geometry): void;
  6986. private _afterRender;
  6987. private _onMessageFromWorker;
  6988. }
  6989. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6990. private _scene;
  6991. private _scaledPosition;
  6992. private _scaledVelocity;
  6993. private _finalPosition;
  6994. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6995. init(scene: Scene): void;
  6996. destroy(): void;
  6997. onMeshAdded(mesh: AbstractMesh): void;
  6998. onMeshUpdated(mesh: AbstractMesh): void;
  6999. onMeshRemoved(mesh: AbstractMesh): void;
  7000. onGeometryAdded(geometry: Geometry): void;
  7001. onGeometryUpdated(geometry: Geometry): void;
  7002. onGeometryDeleted(geometry: Geometry): void;
  7003. private _collideWithWorld;
  7004. }
  7005. }
  7006. declare function importScripts(...urls: string[]): void;
  7007. declare const safePostMessage: any;
  7008. declare module BABYLON {
  7009. var WorkerIncluded: boolean;
  7010. class CollisionCache {
  7011. private _meshes;
  7012. private _geometries;
  7013. getMeshes(): {
  7014. [n: number]: SerializedMesh;
  7015. };
  7016. getGeometries(): {
  7017. [s: number]: SerializedGeometry;
  7018. };
  7019. getMesh(id: any): SerializedMesh;
  7020. addMesh(mesh: SerializedMesh): void;
  7021. removeMesh(uniqueId: number): void;
  7022. getGeometry(id: string): SerializedGeometry;
  7023. addGeometry(geometry: SerializedGeometry): void;
  7024. removeGeometry(id: string): void;
  7025. }
  7026. class CollideWorker {
  7027. collider: Collider;
  7028. private _collisionCache;
  7029. private finalPosition;
  7030. private collisionsScalingMatrix;
  7031. private collisionTranformationMatrix;
  7032. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7033. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7034. private checkCollision;
  7035. private processCollisionsForSubMeshes;
  7036. private collideForSubMesh;
  7037. private checkSubmeshCollision;
  7038. }
  7039. interface ICollisionDetector {
  7040. onInit(payload: InitPayload): void;
  7041. onUpdate(payload: UpdatePayload): void;
  7042. onCollision(payload: CollidePayload): void;
  7043. }
  7044. class CollisionDetectorTransferable implements ICollisionDetector {
  7045. private _collisionCache;
  7046. onInit(payload: InitPayload): void;
  7047. onUpdate(payload: UpdatePayload): void;
  7048. onCollision(payload: CollidePayload): void;
  7049. }
  7050. }
  7051. declare module BABYLON {
  7052. class IntersectionInfo {
  7053. bu: Nullable<number>;
  7054. bv: Nullable<number>;
  7055. distance: number;
  7056. faceId: number;
  7057. subMeshId: number;
  7058. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7059. }
  7060. /**
  7061. * Information about the result of picking within a scene
  7062. * See https://doc.babylonjs.com/babylon101/picking_collisions
  7063. */
  7064. class PickingInfo {
  7065. /**
  7066. * If the pick collided with an object
  7067. */
  7068. hit: boolean;
  7069. /**
  7070. * Distance away where the pick collided
  7071. */
  7072. distance: number;
  7073. /**
  7074. * The location of pick collision
  7075. */
  7076. pickedPoint: Nullable<Vector3>;
  7077. /**
  7078. * The mesh corresponding the the pick collision
  7079. */
  7080. pickedMesh: Nullable<AbstractMesh>;
  7081. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7082. bu: number;
  7083. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7084. bv: number;
  7085. /** The id of the face on the mesh that was picked */
  7086. faceId: number;
  7087. /** Id of the the submesh that was picked */
  7088. subMeshId: number;
  7089. /** If a sprite was picked, this will be the sprite the pick collided with */
  7090. pickedSprite: Nullable<Sprite>;
  7091. /**
  7092. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7093. */
  7094. originMesh: Nullable<AbstractMesh>;
  7095. /**
  7096. * The ray that was used to perform the picking.
  7097. */
  7098. ray: Nullable<Ray>;
  7099. /**
  7100. * Gets the normal correspodning to the face the pick collided with
  7101. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7102. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7103. * @returns The normal correspodning to the face the pick collided with
  7104. */
  7105. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7106. /**
  7107. * Gets the texture coordinates of where the pick occured
  7108. * @returns the vector containing the coordnates of the texture
  7109. */
  7110. getTextureCoordinates(): Nullable<Vector2>;
  7111. }
  7112. }
  7113. declare module BABYLON {
  7114. /**
  7115. * Interface for attribute information associated with buffer instanciation
  7116. */
  7117. class InstancingAttributeInfo {
  7118. /**
  7119. * Index/offset of the attribute in the vertex shader
  7120. */
  7121. index: number;
  7122. /**
  7123. * size of the attribute, 1, 2, 3 or 4
  7124. */
  7125. attributeSize: number;
  7126. /**
  7127. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7128. * default is FLOAT
  7129. */
  7130. attribyteType: number;
  7131. /**
  7132. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7133. */
  7134. normalized: boolean;
  7135. /**
  7136. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7137. */
  7138. offset: number;
  7139. /**
  7140. * Name of the GLSL attribute, for debugging purpose only
  7141. */
  7142. attributeName: string;
  7143. }
  7144. /**
  7145. * Define options used to create a render target texture
  7146. */
  7147. class RenderTargetCreationOptions {
  7148. /**
  7149. * Specifies is mipmaps must be generated
  7150. */
  7151. generateMipMaps?: boolean;
  7152. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7153. generateDepthBuffer?: boolean;
  7154. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7155. generateStencilBuffer?: boolean;
  7156. /** Defines texture type (int by default) */
  7157. type?: number;
  7158. /** Defines sampling mode (trilinear by default) */
  7159. samplingMode?: number;
  7160. /** Defines format (RGBA by default) */
  7161. format?: number;
  7162. }
  7163. /**
  7164. * Define options used to create a depth texture
  7165. */
  7166. class DepthTextureCreationOptions {
  7167. /** Specifies whether or not a stencil should be allocated in the texture */
  7168. generateStencil?: boolean;
  7169. /** Specifies whether or not bilinear filtering is enable on the texture */
  7170. bilinearFiltering?: boolean;
  7171. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7172. comparisonFunction?: number;
  7173. /** Specifies if the created texture is a cube texture */
  7174. isCube?: boolean;
  7175. }
  7176. /**
  7177. * Class used to describe the capabilities of the engine relatively to the current browser
  7178. */
  7179. class EngineCapabilities {
  7180. /** Maximum textures units per fragment shader */
  7181. maxTexturesImageUnits: number;
  7182. /** Maximum texture units per vertex shader */
  7183. maxVertexTextureImageUnits: number;
  7184. /** Maximum textures units in the entire pipeline */
  7185. maxCombinedTexturesImageUnits: number;
  7186. /** Maximum texture size */
  7187. maxTextureSize: number;
  7188. /** Maximum cube texture size */
  7189. maxCubemapTextureSize: number;
  7190. /** Maximum render texture size */
  7191. maxRenderTextureSize: number;
  7192. /** Maximum number of vertex attributes */
  7193. maxVertexAttribs: number;
  7194. /** Maximum number of varyings */
  7195. maxVaryingVectors: number;
  7196. /** Maximum number of uniforms per vertex shader */
  7197. maxVertexUniformVectors: number;
  7198. /** Maximum number of uniforms per fragment shader */
  7199. maxFragmentUniformVectors: number;
  7200. /** Defines if standard derivates (dx/dy) are supported */
  7201. standardDerivatives: boolean;
  7202. /** Defines if s3tc texture compression is supported */
  7203. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7204. /** Defines if pvrtc texture compression is supported */
  7205. pvrtc: any;
  7206. /** Defines if etc1 texture compression is supported */
  7207. etc1: any;
  7208. /** Defines if etc2 texture compression is supported */
  7209. etc2: any;
  7210. /** Defines if astc texture compression is supported */
  7211. astc: any;
  7212. /** Defines if float textures are supported */
  7213. textureFloat: boolean;
  7214. /** Defines if vertex array objects are supported */
  7215. vertexArrayObject: boolean;
  7216. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7217. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7218. /** Gets the maximum level of anisotropy supported */
  7219. maxAnisotropy: number;
  7220. /** Defines if instancing is supported */
  7221. instancedArrays: boolean;
  7222. /** Defines if 32 bits indices are supported */
  7223. uintIndices: boolean;
  7224. /** Defines if high precision shaders are supported */
  7225. highPrecisionShaderSupported: boolean;
  7226. /** Defines if depth reading in the fragment shader is supported */
  7227. fragmentDepthSupported: boolean;
  7228. /** Defines if float texture linear filtering is supported*/
  7229. textureFloatLinearFiltering: boolean;
  7230. /** Defines if rendering to float textures is supported */
  7231. textureFloatRender: boolean;
  7232. /** Defines if half float textures are supported*/
  7233. textureHalfFloat: boolean;
  7234. /** Defines if half float texture linear filtering is supported*/
  7235. textureHalfFloatLinearFiltering: boolean;
  7236. /** Defines if rendering to half float textures is supported */
  7237. textureHalfFloatRender: boolean;
  7238. /** Defines if textureLOD shader command is supported */
  7239. textureLOD: boolean;
  7240. /** Defines if draw buffers extension is supported */
  7241. drawBuffersExtension: boolean;
  7242. /** Defines if depth textures are supported */
  7243. depthTextureExtension: boolean;
  7244. /** Defines if float color buffer are supported */
  7245. colorBufferFloat: boolean;
  7246. /** Gets disjoint timer query extension (null if not supported) */
  7247. timerQuery: EXT_disjoint_timer_query;
  7248. /** Defines if timestamp can be used with timer query */
  7249. canUseTimestampForTimerQuery: boolean;
  7250. }
  7251. /** Interface defining initialization parameters for Engine class */
  7252. interface EngineOptions extends WebGLContextAttributes {
  7253. /**
  7254. * Defines if the engine should no exceed a specified device ratio
  7255. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7256. */
  7257. limitDeviceRatio?: number;
  7258. /**
  7259. * Defines if webvr should be enabled automatically
  7260. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7261. */
  7262. autoEnableWebVR?: boolean;
  7263. /**
  7264. * Defines if webgl2 should be turned off even if supported
  7265. * @see http://doc.babylonjs.com/features/webgl2
  7266. */
  7267. disableWebGL2Support?: boolean;
  7268. /**
  7269. * Defines if webaudio should be initialized as well
  7270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7271. */
  7272. audioEngine?: boolean;
  7273. /**
  7274. * Defines if animations should run using a deterministic lock step
  7275. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7276. */
  7277. deterministicLockstep?: boolean;
  7278. /** Defines the maximum steps to use with deterministic lock step mode */
  7279. lockstepMaxSteps?: number;
  7280. /**
  7281. * Defines that engine should ignore context lost events
  7282. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7283. */
  7284. doNotHandleContextLost?: boolean;
  7285. }
  7286. /**
  7287. * Defines the interface used by display changed events
  7288. */
  7289. interface IDisplayChangedEventArgs {
  7290. /** Gets the vrDisplay object (if any) */
  7291. vrDisplay: Nullable<any>;
  7292. /** Gets a boolean indicating if webVR is supported */
  7293. vrSupported: boolean;
  7294. }
  7295. /**
  7296. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7297. */
  7298. class Engine {
  7299. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7300. static ExceptionList: ({
  7301. key: string;
  7302. capture: string;
  7303. captureConstraint: number;
  7304. targets: string[];
  7305. } | {
  7306. key: string;
  7307. capture: null;
  7308. captureConstraint: null;
  7309. targets: string[];
  7310. })[];
  7311. /** Gets the list of created engines */
  7312. static Instances: Engine[];
  7313. /**
  7314. * Gets the latest created engine
  7315. */
  7316. static readonly LastCreatedEngine: Nullable<Engine>;
  7317. /**
  7318. * Gets the latest created scene
  7319. */
  7320. static readonly LastCreatedScene: Nullable<Scene>;
  7321. /**
  7322. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7323. * @param flag defines which part of the materials must be marked as dirty
  7324. * @param predicate defines a predicate used to filter which materials should be affected
  7325. */
  7326. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7327. /**
  7328. * Hidden
  7329. */
  7330. static _TextureLoaders: IInternalTextureLoader[];
  7331. /** Defines that alpha blending is disabled */
  7332. static readonly ALPHA_DISABLE: number;
  7333. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7334. static readonly ALPHA_ADD: number;
  7335. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7336. static readonly ALPHA_COMBINE: number;
  7337. /** Defines that alpha blending to DEST - SRC * DEST */
  7338. static readonly ALPHA_SUBTRACT: number;
  7339. /** Defines that alpha blending to SRC * DEST */
  7340. static readonly ALPHA_MULTIPLY: number;
  7341. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7342. static readonly ALPHA_MAXIMIZED: number;
  7343. /** Defines that alpha blending to SRC + DEST */
  7344. static readonly ALPHA_ONEONE: number;
  7345. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7346. static readonly ALPHA_PREMULTIPLIED: number;
  7347. /**
  7348. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7349. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7350. */
  7351. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7352. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7353. static readonly ALPHA_INTERPOLATE: number;
  7354. /**
  7355. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7356. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7357. */
  7358. static readonly ALPHA_SCREENMODE: number;
  7359. /** Defines that the ressource is not delayed*/
  7360. static readonly DELAYLOADSTATE_NONE: number;
  7361. /** Defines that the ressource was successfully delay loaded */
  7362. static readonly DELAYLOADSTATE_LOADED: number;
  7363. /** Defines that the ressource is currently delay loading */
  7364. static readonly DELAYLOADSTATE_LOADING: number;
  7365. /** Defines that the ressource is delayed and has not started loading */
  7366. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7367. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7368. static readonly NEVER: number;
  7369. /** 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 */
  7370. static readonly ALWAYS: number;
  7371. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7372. static readonly LESS: number;
  7373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7374. static readonly EQUAL: number;
  7375. /** 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 */
  7376. static readonly LEQUAL: number;
  7377. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7378. static readonly GREATER: number;
  7379. /** 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 */
  7380. static readonly GEQUAL: number;
  7381. /** 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 */
  7382. static readonly NOTEQUAL: number;
  7383. /** Passed to stencilOperation to specify that stencil value must be kept */
  7384. static readonly KEEP: number;
  7385. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7386. static readonly REPLACE: number;
  7387. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7388. static readonly INCR: number;
  7389. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7390. static readonly DECR: number;
  7391. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7392. static readonly INVERT: number;
  7393. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7394. static readonly INCR_WRAP: number;
  7395. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7396. static readonly DECR_WRAP: number;
  7397. /** Texture is not repeating outside of 0..1 UVs */
  7398. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7399. /** Texture is repeating outside of 0..1 UVs */
  7400. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7401. /** Texture is repeating and mirrored */
  7402. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7403. /** ALPHA */
  7404. static readonly TEXTUREFORMAT_ALPHA: number;
  7405. /** LUMINANCE */
  7406. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7407. /** LUMINANCE_ALPHA */
  7408. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7409. /** RGB */
  7410. static readonly TEXTUREFORMAT_RGB: number;
  7411. /** RGBA */
  7412. static readonly TEXTUREFORMAT_RGBA: number;
  7413. /** R */
  7414. static readonly TEXTUREFORMAT_R: number;
  7415. /** RG */
  7416. static readonly TEXTUREFORMAT_RG: number;
  7417. /** UNSIGNED_INT */
  7418. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7419. /** FLOAT */
  7420. static readonly TEXTURETYPE_FLOAT: number;
  7421. /** HALF_FLOAT */
  7422. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7423. /** nearest is mag = nearest and min = nearest and mip = linear */
  7424. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7425. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7426. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7427. /** Trilinear is mag = linear and min = linear and mip = linear */
  7428. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7429. /** nearest is mag = nearest and min = nearest and mip = linear */
  7430. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7432. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7433. /** Trilinear is mag = linear and min = linear and mip = linear */
  7434. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7435. /** mag = nearest and min = nearest and mip = nearest */
  7436. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7437. /** mag = nearest and min = linear and mip = nearest */
  7438. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7439. /** mag = nearest and min = linear and mip = linear */
  7440. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7441. /** mag = nearest and min = linear and mip = none */
  7442. static readonly TEXTURE_NEAREST_LINEAR: number;
  7443. /** mag = nearest and min = nearest and mip = none */
  7444. static readonly TEXTURE_NEAREST_NEAREST: number;
  7445. /** mag = linear and min = nearest and mip = nearest */
  7446. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7447. /** mag = linear and min = nearest and mip = linear */
  7448. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7449. /** mag = linear and min = linear and mip = none */
  7450. static readonly TEXTURE_LINEAR_LINEAR: number;
  7451. /** mag = linear and min = nearest and mip = none */
  7452. static readonly TEXTURE_LINEAR_NEAREST: number;
  7453. /** Explicit coordinates mode */
  7454. static readonly TEXTURE_EXPLICIT_MODE: number;
  7455. /** Spherical coordinates mode */
  7456. static readonly TEXTURE_SPHERICAL_MODE: number;
  7457. /** Planar coordinates mode */
  7458. static readonly TEXTURE_PLANAR_MODE: number;
  7459. /** Cubic coordinates mode */
  7460. static readonly TEXTURE_CUBIC_MODE: number;
  7461. /** Projection coordinates mode */
  7462. static readonly TEXTURE_PROJECTION_MODE: number;
  7463. /** Skybox coordinates mode */
  7464. static readonly TEXTURE_SKYBOX_MODE: number;
  7465. /** Inverse Cubic coordinates mode */
  7466. static readonly TEXTURE_INVCUBIC_MODE: number;
  7467. /** Equirectangular coordinates mode */
  7468. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7469. /** Equirectangular Fixed coordinates mode */
  7470. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7471. /** Equirectangular Fixed Mirrored coordinates mode */
  7472. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7473. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7474. static readonly SCALEMODE_FLOOR: number;
  7475. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7476. static readonly SCALEMODE_NEAREST: number;
  7477. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7478. static readonly SCALEMODE_CEILING: number;
  7479. /**
  7480. * Returns the current version of the framework
  7481. */
  7482. static readonly Version: string;
  7483. /**
  7484. * Gets or sets the epsilon value used by collision engine
  7485. */
  7486. static CollisionsEpsilon: number;
  7487. /**
  7488. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7489. */
  7490. static CodeRepository: string;
  7491. /**
  7492. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7493. */
  7494. static ShadersRepository: string;
  7495. /**
  7496. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7497. */
  7498. forcePOTTextures: boolean;
  7499. /**
  7500. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7501. */
  7502. isFullscreen: boolean;
  7503. /**
  7504. * Gets a boolean indicating if the pointer is currently locked
  7505. */
  7506. isPointerLock: boolean;
  7507. /**
  7508. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7509. */
  7510. cullBackFaces: boolean;
  7511. /**
  7512. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7513. */
  7514. renderEvenInBackground: boolean;
  7515. /**
  7516. * Gets or sets a boolean indicating that cache can be kept between frames
  7517. */
  7518. preventCacheWipeBetweenFrames: boolean;
  7519. /**
  7520. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7521. **/
  7522. enableOfflineSupport: boolean;
  7523. /**
  7524. * 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)
  7525. **/
  7526. disableManifestCheck: boolean;
  7527. /**
  7528. * Gets the list of created scenes
  7529. */
  7530. scenes: Scene[];
  7531. /**
  7532. * Gets the list of created postprocesses
  7533. */
  7534. postProcesses: PostProcess[];
  7535. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7536. validateShaderPrograms: boolean;
  7537. /**
  7538. * Observable event triggered each time the rendering canvas is resized
  7539. */
  7540. onResizeObservable: Observable<Engine>;
  7541. /**
  7542. * Observable event triggered each time the canvas loses focus
  7543. */
  7544. onCanvasBlurObservable: Observable<Engine>;
  7545. /**
  7546. * Observable event triggered each time the canvas gains focus
  7547. */
  7548. onCanvasFocusObservable: Observable<Engine>;
  7549. /**
  7550. * Observable event triggered each time the canvas receives pointerout event
  7551. */
  7552. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7553. /**
  7554. * Observable event triggered before each texture is initialized
  7555. */
  7556. onBeforeTextureInitObservable: Observable<Texture>;
  7557. private _vrDisplay;
  7558. private _vrSupported;
  7559. private _oldSize;
  7560. private _oldHardwareScaleFactor;
  7561. private _vrExclusivePointerMode;
  7562. private _webVRInitPromise;
  7563. /**
  7564. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7565. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7566. */
  7567. readonly isInVRExclusivePointerMode: boolean;
  7568. /**
  7569. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7570. */
  7571. disableUniformBuffers: boolean;
  7572. /** @hidden */
  7573. _uniformBuffers: UniformBuffer[];
  7574. /**
  7575. * Gets a boolean indicating that the engine supports uniform buffers
  7576. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7577. */
  7578. readonly supportsUniformBuffers: boolean;
  7579. /**
  7580. * Observable raised when the engine begins a new frame
  7581. */
  7582. onBeginFrameObservable: Observable<Engine>;
  7583. /**
  7584. * Observable raised when the engine ends the current frame
  7585. */
  7586. onEndFrameObservable: Observable<Engine>;
  7587. /**
  7588. * Observable raised when the engine is about to compile a shader
  7589. */
  7590. onBeforeShaderCompilationObservable: Observable<Engine>;
  7591. /**
  7592. * Observable raised when the engine has jsut compiled a shader
  7593. */
  7594. onAfterShaderCompilationObservable: Observable<Engine>;
  7595. /** @hidden */
  7596. _gl: WebGLRenderingContext;
  7597. private _renderingCanvas;
  7598. private _windowIsBackground;
  7599. private _webGLVersion;
  7600. /**
  7601. * Gets a boolean indicating that only power of 2 textures are supported
  7602. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7603. */
  7604. readonly needPOTTextures: boolean;
  7605. /** @hidden */
  7606. _badOS: boolean;
  7607. /** @hidden */
  7608. _badDesktopOS: boolean;
  7609. /**
  7610. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7611. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7612. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7613. */
  7614. disableTextureBindingOptimization: boolean;
  7615. /**
  7616. * Gets the audio engine
  7617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7618. * @ignorenaming
  7619. */
  7620. static audioEngine: AudioEngine;
  7621. private _onFocus;
  7622. private _onBlur;
  7623. private _onCanvasPointerOut;
  7624. private _onCanvasBlur;
  7625. private _onCanvasFocus;
  7626. private _onFullscreenChange;
  7627. private _onPointerLockChange;
  7628. private _onVRDisplayPointerRestricted;
  7629. private _onVRDisplayPointerUnrestricted;
  7630. private _onVrDisplayConnect;
  7631. private _onVrDisplayDisconnect;
  7632. private _onVrDisplayPresentChange;
  7633. /**
  7634. * Observable signaled when VR display mode changes
  7635. */
  7636. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7637. /**
  7638. * Observable signaled when VR request present is complete
  7639. */
  7640. onVRRequestPresentComplete: Observable<boolean>;
  7641. /**
  7642. * Observable signaled when VR request present starts
  7643. */
  7644. onVRRequestPresentStart: Observable<Engine>;
  7645. private _hardwareScalingLevel;
  7646. /** @hidden */
  7647. protected _caps: EngineCapabilities;
  7648. private _pointerLockRequested;
  7649. private _isStencilEnable;
  7650. private _colorWrite;
  7651. private _loadingScreen;
  7652. /** @hidden */
  7653. _drawCalls: PerfCounter;
  7654. /** @hidden */
  7655. _textureCollisions: PerfCounter;
  7656. private _glVersion;
  7657. private _glRenderer;
  7658. private _glVendor;
  7659. private _videoTextureSupported;
  7660. private _renderingQueueLaunched;
  7661. private _activeRenderLoops;
  7662. private _deterministicLockstep;
  7663. private _lockstepMaxSteps;
  7664. /**
  7665. * Observable signaled when a context lost event is raised
  7666. */
  7667. onContextLostObservable: Observable<Engine>;
  7668. /**
  7669. * Observable signaled when a context restored event is raised
  7670. */
  7671. onContextRestoredObservable: Observable<Engine>;
  7672. private _onContextLost;
  7673. private _onContextRestored;
  7674. private _contextWasLost;
  7675. private _doNotHandleContextLost;
  7676. /**
  7677. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7679. */
  7680. doNotHandleContextLost: boolean;
  7681. private _performanceMonitor;
  7682. private _fps;
  7683. private _deltaTime;
  7684. /**
  7685. * Turn this value on if you want to pause FPS computation when in background
  7686. */
  7687. disablePerformanceMonitorInBackground: boolean;
  7688. /**
  7689. * Gets the performance monitor attached to this engine
  7690. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7691. */
  7692. readonly performanceMonitor: PerformanceMonitor;
  7693. /** @hidden */
  7694. protected _depthCullingState: _DepthCullingState;
  7695. /** @hidden */
  7696. protected _stencilState: _StencilState;
  7697. /** @hidden */
  7698. protected _alphaState: _AlphaState;
  7699. /** @hidden */
  7700. protected _alphaMode: number;
  7701. protected _internalTexturesCache: InternalTexture[];
  7702. /** @hidden */
  7703. protected _activeChannel: number;
  7704. private _currentTextureChannel;
  7705. /** @hidden */
  7706. protected _boundTexturesCache: {
  7707. [key: string]: Nullable<InternalTexture>;
  7708. };
  7709. /** @hidden */
  7710. protected _currentEffect: Nullable<Effect>;
  7711. /** @hidden */
  7712. protected _currentProgram: Nullable<WebGLProgram>;
  7713. private _compiledEffects;
  7714. private _vertexAttribArraysEnabled;
  7715. /** @hidden */
  7716. protected _cachedViewport: Nullable<Viewport>;
  7717. private _cachedVertexArrayObject;
  7718. /** @hidden */
  7719. protected _cachedVertexBuffers: any;
  7720. /** @hidden */
  7721. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7722. /** @hidden */
  7723. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7724. /** @hidden */
  7725. protected _currentRenderTarget: Nullable<InternalTexture>;
  7726. private _uintIndicesCurrentlySet;
  7727. private _currentBoundBuffer;
  7728. /** @hidden */
  7729. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7730. private _currentBufferPointers;
  7731. private _currentInstanceLocations;
  7732. private _currentInstanceBuffers;
  7733. private _textureUnits;
  7734. private _firstBoundInternalTextureTracker;
  7735. private _lastBoundInternalTextureTracker;
  7736. private _workingCanvas;
  7737. private _workingContext;
  7738. private _rescalePostProcess;
  7739. private _dummyFramebuffer;
  7740. private _externalData;
  7741. private _bindedRenderFunction;
  7742. private _vaoRecordInProgress;
  7743. private _mustWipeVertexAttributes;
  7744. private _emptyTexture;
  7745. private _emptyCubeTexture;
  7746. private _emptyTexture3D;
  7747. private _frameHandler;
  7748. private _nextFreeTextureSlots;
  7749. private _maxSimultaneousTextures;
  7750. private _activeRequests;
  7751. private _texturesSupported;
  7752. private _textureFormatInUse;
  7753. /**
  7754. * Gets the list of texture formats supported
  7755. */
  7756. readonly texturesSupported: Array<string>;
  7757. /**
  7758. * Gets the list of texture formats in use
  7759. */
  7760. readonly textureFormatInUse: Nullable<string>;
  7761. /**
  7762. * Gets the current viewport
  7763. */
  7764. readonly currentViewport: Nullable<Viewport>;
  7765. /**
  7766. * Gets the default empty texture
  7767. */
  7768. readonly emptyTexture: InternalTexture;
  7769. /**
  7770. * Gets the default empty 3D texture
  7771. */
  7772. readonly emptyTexture3D: InternalTexture;
  7773. /**
  7774. * Gets the default empty cube texture
  7775. */
  7776. readonly emptyCubeTexture: InternalTexture;
  7777. /**
  7778. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7779. */
  7780. readonly premultipliedAlpha: boolean;
  7781. /**
  7782. * Creates a new engine
  7783. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7784. * @param antialias defines enable antialiasing (default: false)
  7785. * @param options defines further options to be sent to the getContext() function
  7786. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7787. */
  7788. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7789. private _rebuildInternalTextures;
  7790. private _rebuildEffects;
  7791. private _rebuildBuffers;
  7792. private _initGLContext;
  7793. /**
  7794. * Gets version of the current webGL context
  7795. */
  7796. readonly webGLVersion: number;
  7797. /**
  7798. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7799. */
  7800. readonly isStencilEnable: boolean;
  7801. private _prepareWorkingCanvas;
  7802. /**
  7803. * Reset the texture cache to empty state
  7804. */
  7805. resetTextureCache(): void;
  7806. /**
  7807. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7808. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7809. * @returns true if engine is in deterministic lock step mode
  7810. */
  7811. isDeterministicLockStep(): boolean;
  7812. /**
  7813. * Gets the max steps when engine is running in deterministic lock step
  7814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7815. * @returns the max steps
  7816. */
  7817. getLockstepMaxSteps(): number;
  7818. /**
  7819. * Gets an object containing information about the current webGL context
  7820. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7821. */
  7822. getGlInfo(): {
  7823. vendor: string;
  7824. renderer: string;
  7825. version: string;
  7826. };
  7827. /**
  7828. * Gets current aspect ratio
  7829. * @param camera defines the camera to use to get the aspect ratio
  7830. * @param useScreen defines if screen size must be used (or the current render target if any)
  7831. * @returns a number defining the aspect ratio
  7832. */
  7833. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7834. /**
  7835. * Gets current screen aspect ratio
  7836. * @returns a number defining the aspect ratio
  7837. */
  7838. getScreenAspectRatio(): number;
  7839. /**
  7840. * Gets the current render width
  7841. * @param useScreen defines if screen size must be used (or the current render target if any)
  7842. * @returns a number defining the current render width
  7843. */
  7844. getRenderWidth(useScreen?: boolean): number;
  7845. /**
  7846. * Gets the current render height
  7847. * @param useScreen defines if screen size must be used (or the current render target if any)
  7848. * @returns a number defining the current render height
  7849. */
  7850. getRenderHeight(useScreen?: boolean): number;
  7851. /**
  7852. * Gets the HTML canvas attached with the current webGL context
  7853. * @returns a HTML canvas
  7854. */
  7855. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7856. /**
  7857. * Gets the client rect of the HTML canvas attached with the current webGL context
  7858. * @returns a client rectanglee
  7859. */
  7860. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7861. /**
  7862. * Defines the hardware scaling level.
  7863. * By default the hardware scaling level is computed from the window device ratio.
  7864. * 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.
  7865. * @param level defines the level to use
  7866. */
  7867. setHardwareScalingLevel(level: number): void;
  7868. /**
  7869. * Gets the current hardware scaling level.
  7870. * By default the hardware scaling level is computed from the window device ratio.
  7871. * 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.
  7872. * @returns a number indicating the current hardware scaling level
  7873. */
  7874. getHardwareScalingLevel(): number;
  7875. /**
  7876. * Gets the list of loaded textures
  7877. * @returns an array containing all loaded textures
  7878. */
  7879. getLoadedTexturesCache(): InternalTexture[];
  7880. /**
  7881. * Gets the object containing all engine capabilities
  7882. * @returns the EngineCapabilities object
  7883. */
  7884. getCaps(): EngineCapabilities;
  7885. /** @hidden */
  7886. readonly drawCalls: number;
  7887. /** @hidden */
  7888. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7889. /**
  7890. * Gets the current depth function
  7891. * @returns a number defining the depth function
  7892. */
  7893. getDepthFunction(): Nullable<number>;
  7894. /**
  7895. * Sets the current depth function
  7896. * @param depthFunc defines the function to use
  7897. */
  7898. setDepthFunction(depthFunc: number): void;
  7899. /**
  7900. * Sets the current depth function to GREATER
  7901. */
  7902. setDepthFunctionToGreater(): void;
  7903. /**
  7904. * Sets the current depth function to GEQUAL
  7905. */
  7906. setDepthFunctionToGreaterOrEqual(): void;
  7907. /**
  7908. * Sets the current depth function to LESS
  7909. */
  7910. setDepthFunctionToLess(): void;
  7911. /**
  7912. * Sets the current depth function to LEQUAL
  7913. */
  7914. setDepthFunctionToLessOrEqual(): void;
  7915. /**
  7916. * Gets a boolean indicating if stencil buffer is enabled
  7917. * @returns the current stencil buffer state
  7918. */
  7919. getStencilBuffer(): boolean;
  7920. /**
  7921. * Enable or disable the stencil buffer
  7922. * @param enable defines if the stencil buffer must be enabled or disabled
  7923. */
  7924. setStencilBuffer(enable: boolean): void;
  7925. /**
  7926. * Gets the current stencil mask
  7927. * @returns a number defining the new stencil mask to use
  7928. */
  7929. getStencilMask(): number;
  7930. /**
  7931. * Sets the current stencil mask
  7932. * @param mask defines the new stencil mask to use
  7933. */
  7934. setStencilMask(mask: number): void;
  7935. /**
  7936. * Gets the current stencil function
  7937. * @returns a number defining the stencil function to use
  7938. */
  7939. getStencilFunction(): number;
  7940. /**
  7941. * Gets the current stencil reference value
  7942. * @returns a number defining the stencil reference value to use
  7943. */
  7944. getStencilFunctionReference(): number;
  7945. /**
  7946. * Gets the current stencil mask
  7947. * @returns a number defining the stencil mask to use
  7948. */
  7949. getStencilFunctionMask(): number;
  7950. /**
  7951. * Sets the current stencil function
  7952. * @param stencilFunc defines the new stencil function to use
  7953. */
  7954. setStencilFunction(stencilFunc: number): void;
  7955. /**
  7956. * Sets the current stencil reference
  7957. * @param reference defines the new stencil reference to use
  7958. */
  7959. setStencilFunctionReference(reference: number): void;
  7960. /**
  7961. * Sets the current stencil mask
  7962. * @param mask defines the new stencil mask to use
  7963. */
  7964. setStencilFunctionMask(mask: number): void;
  7965. /**
  7966. * Gets the current stencil operation when stencil fails
  7967. * @returns a number defining stencil operation to use when stencil fails
  7968. */
  7969. getStencilOperationFail(): number;
  7970. /**
  7971. * Gets the current stencil operation when depth fails
  7972. * @returns a number defining stencil operation to use when depth fails
  7973. */
  7974. getStencilOperationDepthFail(): number;
  7975. /**
  7976. * Gets the current stencil operation when stencil passes
  7977. * @returns a number defining stencil operation to use when stencil passes
  7978. */
  7979. getStencilOperationPass(): number;
  7980. /**
  7981. * Sets the stencil operation to use when stencil fails
  7982. * @param operation defines the stencil operation to use when stencil fails
  7983. */
  7984. setStencilOperationFail(operation: number): void;
  7985. /**
  7986. * Sets the stencil operation to use when depth fails
  7987. * @param operation defines the stencil operation to use when depth fails
  7988. */
  7989. setStencilOperationDepthFail(operation: number): void;
  7990. /**
  7991. * Sets the stencil operation to use when stencil passes
  7992. * @param operation defines the stencil operation to use when stencil passes
  7993. */
  7994. setStencilOperationPass(operation: number): void;
  7995. /**
  7996. * Sets a boolean indicating if the dithering state is enabled or disabled
  7997. * @param value defines the dithering state
  7998. */
  7999. setDitheringState(value: boolean): void;
  8000. /**
  8001. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  8002. * @param value defines the rasterizer state
  8003. */
  8004. setRasterizerState(value: boolean): void;
  8005. /**
  8006. * stop executing a render loop function and remove it from the execution array
  8007. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  8008. */
  8009. stopRenderLoop(renderFunction?: () => void): void;
  8010. /** @hidden */
  8011. _renderLoop(): void;
  8012. /**
  8013. * Register and execute a render loop. The engine can have more than one render function
  8014. * @param renderFunction defines the function to continuously execute
  8015. */
  8016. runRenderLoop(renderFunction: () => void): void;
  8017. /**
  8018. * Toggle full screen mode
  8019. * @param requestPointerLock defines if a pointer lock should be requested from the user
  8020. * @param options defines an option object to be sent to the requestFullscreen function
  8021. */
  8022. switchFullscreen(requestPointerLock: boolean): void;
  8023. /**
  8024. * Clear the current render buffer or the current render target (if any is set up)
  8025. * @param color defines the color to use
  8026. * @param backBuffer defines if the back buffer must be cleared
  8027. * @param depth defines if the depth buffer must be cleared
  8028. * @param stencil defines if the stencil buffer must be cleared
  8029. */
  8030. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8031. /**
  8032. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  8033. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  8034. * @param y defines the y-coordinate of the corner of the clear rectangle
  8035. * @param width defines the width of the clear rectangle
  8036. * @param height defines the height of the clear rectangle
  8037. * @param clearColor defines the clear color
  8038. */
  8039. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  8040. private _viewportCached;
  8041. /** @hidden */
  8042. _viewport(x: number, y: number, width: number, height: number): void;
  8043. /**
  8044. * Set the WebGL's viewport
  8045. * @param viewport defines the viewport element to be used
  8046. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  8047. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  8048. */
  8049. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8050. /**
  8051. * Directly set the WebGL Viewport
  8052. * @param x defines the x coordinate of the viewport (in screen space)
  8053. * @param y defines the y coordinate of the viewport (in screen space)
  8054. * @param width defines the width of the viewport (in screen space)
  8055. * @param height defines the height of the viewport (in screen space)
  8056. * @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
  8057. */
  8058. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8059. /**
  8060. * Begin a new frame
  8061. */
  8062. beginFrame(): void;
  8063. /**
  8064. * Enf the current frame
  8065. */
  8066. endFrame(): void;
  8067. /**
  8068. * Resize the view according to the canvas' size
  8069. */
  8070. resize(): void;
  8071. /**
  8072. * Force a specific size of the canvas
  8073. * @param width defines the new canvas' width
  8074. * @param height defines the new canvas' height
  8075. */
  8076. setSize(width: number, height: number): void;
  8077. /**
  8078. * Gets a boolean indicating if a webVR device was detected
  8079. * @returns true if a webVR device was detected
  8080. */
  8081. isVRDevicePresent(): boolean;
  8082. /**
  8083. * Gets the current webVR device
  8084. * @returns the current webVR device (or null)
  8085. */
  8086. getVRDevice(): any;
  8087. /**
  8088. * Initializes a webVR display and starts listening to display change events
  8089. * The onVRDisplayChangedObservable will be notified upon these changes
  8090. * @returns The onVRDisplayChangedObservable
  8091. */
  8092. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8093. /**
  8094. * Initializes a webVR display and starts listening to display change events
  8095. * The onVRDisplayChangedObservable will be notified upon these changes
  8096. * @returns A promise containing a VRDisplay and if vr is supported
  8097. */
  8098. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8099. /**
  8100. * Call this function to switch to webVR mode
  8101. * Will do nothing if webVR is not supported or if there is no webVR device
  8102. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8103. */
  8104. enableVR(): void;
  8105. /**
  8106. * Call this function to leave webVR mode
  8107. * Will do nothing if webVR is not supported or if there is no webVR device
  8108. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8109. */
  8110. disableVR(): void;
  8111. private _onVRFullScreenTriggered;
  8112. private _getVRDisplaysAsync;
  8113. /**
  8114. * Binds the frame buffer to the specified texture.
  8115. * @param texture The texture to render to or null for the default canvas
  8116. * @param faceIndex The face of the texture to render to in case of cube texture
  8117. * @param requiredWidth The width of the target to render to
  8118. * @param requiredHeight The height of the target to render to
  8119. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8120. * @param depthStencilTexture The depth stencil texture to use to render
  8121. * @param lodLevel defines le lod level to bind to the frame buffer
  8122. */
  8123. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8124. private bindUnboundFramebuffer;
  8125. /**
  8126. * Unbind the current render target texture from the webGL context
  8127. * @param texture defines the render target texture to unbind
  8128. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8129. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8130. */
  8131. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8132. /**
  8133. * Unbind a list of render target textures from the webGL context
  8134. * This is used only when drawBuffer extension or webGL2 are active
  8135. * @param textures defines the render target textures to unbind
  8136. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8137. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8138. */
  8139. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8140. /**
  8141. * Force the mipmap generation for the given render target texture
  8142. * @param texture defines the render target texture to use
  8143. */
  8144. generateMipMapsForCubemap(texture: InternalTexture): void;
  8145. /**
  8146. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8147. */
  8148. flushFramebuffer(): void;
  8149. /**
  8150. * Unbind the current render target and bind the default framebuffer
  8151. */
  8152. restoreDefaultFramebuffer(): void;
  8153. /**
  8154. * Create an uniform buffer
  8155. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8156. * @param elements defines the content of the uniform buffer
  8157. * @returns the webGL uniform buffer
  8158. */
  8159. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8160. /**
  8161. * Create a dynamic uniform buffer
  8162. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8163. * @param elements defines the content of the uniform buffer
  8164. * @returns the webGL uniform buffer
  8165. */
  8166. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8167. /**
  8168. * Update an existing uniform buffer
  8169. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8170. * @param uniformBuffer defines the target uniform buffer
  8171. * @param elements defines the content to update
  8172. * @param offset defines the offset in the uniform buffer where update should start
  8173. * @param count defines the size of the data to update
  8174. */
  8175. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8176. private _resetVertexBufferBinding;
  8177. /**
  8178. * Creates a vertex buffer
  8179. * @param data the data for the vertex buffer
  8180. * @returns the new WebGL static buffer
  8181. */
  8182. createVertexBuffer(data: DataArray): WebGLBuffer;
  8183. /**
  8184. * Creates a dynamic vertex buffer
  8185. * @param data the data for the dynamic vertex buffer
  8186. * @returns the new WebGL dynamic buffer
  8187. */
  8188. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8189. /**
  8190. * Update a dynamic index buffer
  8191. * @param indexBuffer defines the target index buffer
  8192. * @param indices defines the data to update
  8193. * @param offset defines the offset in the target index buffer where update should start
  8194. */
  8195. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8196. /**
  8197. * Updates a dynamic vertex buffer.
  8198. * @param vertexBuffer the vertex buffer to update
  8199. * @param data the data used to update the vertex buffer
  8200. * @param byteOffset the byte offset of the data
  8201. * @param byteLength the byte length of the data
  8202. */
  8203. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8204. private _resetIndexBufferBinding;
  8205. /**
  8206. * Creates a new index buffer
  8207. * @param indices defines the content of the index buffer
  8208. * @param updatable defines if the index buffer must be updatable
  8209. * @returns a new webGL buffer
  8210. */
  8211. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8212. /**
  8213. * Bind a webGL buffer to the webGL context
  8214. * @param buffer defines the buffer to bind
  8215. */
  8216. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8217. /**
  8218. * Bind an uniform buffer to the current webGL context
  8219. * @param buffer defines the buffer to bind
  8220. */
  8221. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8222. /**
  8223. * Bind a buffer to the current webGL context at a given location
  8224. * @param buffer defines the buffer to bind
  8225. * @param location defines the index where to bind the buffer
  8226. */
  8227. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8228. /**
  8229. * Bind a specific block at a given index in a specific shader program
  8230. * @param shaderProgram defines the shader program
  8231. * @param blockName defines the block name
  8232. * @param index defines the index where to bind the block
  8233. */
  8234. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8235. private bindIndexBuffer;
  8236. private bindBuffer;
  8237. /**
  8238. * update the bound buffer with the given data
  8239. * @param data defines the data to update
  8240. */
  8241. updateArrayBuffer(data: Float32Array): void;
  8242. private _vertexAttribPointer;
  8243. private _bindIndexBufferWithCache;
  8244. private _bindVertexBuffersAttributes;
  8245. /**
  8246. * Records a vertex array object
  8247. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8248. * @param vertexBuffers defines the list of vertex buffers to store
  8249. * @param indexBuffer defines the index buffer to store
  8250. * @param effect defines the effect to store
  8251. * @returns the new vertex array object
  8252. */
  8253. recordVertexArrayObject(vertexBuffers: {
  8254. [key: string]: VertexBuffer;
  8255. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8256. /**
  8257. * Bind a specific vertex array object
  8258. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8259. * @param vertexArrayObject defines the vertex array object to bind
  8260. * @param indexBuffer defines the index buffer to bind
  8261. */
  8262. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8263. /**
  8264. * Bind webGl buffers directly to the webGL context
  8265. * @param vertexBuffer defines the vertex buffer to bind
  8266. * @param indexBuffer defines the index buffer to bind
  8267. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8268. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8269. * @param effect defines the effect associated with the vertex buffer
  8270. */
  8271. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8272. private _unbindVertexArrayObject;
  8273. /**
  8274. * Bind a list of vertex buffers to the webGL context
  8275. * @param vertexBuffers defines the list of vertex buffers to bind
  8276. * @param indexBuffer defines the index buffer to bind
  8277. * @param effect defines the effect associated with the vertex buffers
  8278. */
  8279. bindBuffers(vertexBuffers: {
  8280. [key: string]: Nullable<VertexBuffer>;
  8281. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8282. /**
  8283. * Unbind all instance attributes
  8284. */
  8285. unbindInstanceAttributes(): void;
  8286. /**
  8287. * Release and free the memory of a vertex array object
  8288. * @param vao defines the vertex array object to delete
  8289. */
  8290. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8291. /** @hidden */
  8292. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8293. /**
  8294. * Creates a webGL buffer to use with instanciation
  8295. * @param capacity defines the size of the buffer
  8296. * @returns the webGL buffer
  8297. */
  8298. createInstancesBuffer(capacity: number): WebGLBuffer;
  8299. /**
  8300. * Delete a webGL buffer used with instanciation
  8301. * @param buffer defines the webGL buffer to delete
  8302. */
  8303. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8304. /**
  8305. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8306. * @param instancesBuffer defines the webGL buffer to update and bind
  8307. * @param data defines the data to store in the buffer
  8308. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8309. */
  8310. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8311. /**
  8312. * Apply all cached states (depth, culling, stencil and alpha)
  8313. */
  8314. applyStates(): void;
  8315. /**
  8316. * Send a draw order
  8317. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8318. * @param indexStart defines the starting index
  8319. * @param indexCount defines the number of index to draw
  8320. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8321. */
  8322. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8323. /**
  8324. * Draw a list of points
  8325. * @param verticesStart defines the index of first vertex to draw
  8326. * @param verticesCount defines the count of vertices to draw
  8327. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8328. */
  8329. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8330. /**
  8331. * Draw a list of unindexed primitives
  8332. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8333. * @param verticesStart defines the index of first vertex to draw
  8334. * @param verticesCount defines the count of vertices to draw
  8335. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8336. */
  8337. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8338. /**
  8339. * Draw a list of indexed primitives
  8340. * @param fillMode defines the primitive to use
  8341. * @param indexStart defines the starting index
  8342. * @param indexCount defines the number of index to draw
  8343. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8344. */
  8345. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8346. /**
  8347. * Draw a list of unindexed primitives
  8348. * @param fillMode defines the primitive to use
  8349. * @param verticesStart defines the index of first vertex to draw
  8350. * @param verticesCount defines the count of vertices to draw
  8351. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8352. */
  8353. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8354. private _drawMode;
  8355. /** @hidden */
  8356. _releaseEffect(effect: Effect): void;
  8357. /** @hidden */
  8358. _deleteProgram(program: WebGLProgram): void;
  8359. /**
  8360. * Create a new effect (used to store vertex/fragment shaders)
  8361. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8362. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8363. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8364. * @param samplers defines an array of string used to represent textures
  8365. * @param defines defines the string containing the defines to use to compile the shaders
  8366. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8367. * @param onCompiled defines a function to call when the effect creation is successful
  8368. * @param onError defines a function to call when the effect creation has failed
  8369. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8370. * @returns the new Effect
  8371. */
  8372. 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;
  8373. private _compileShader;
  8374. private _compileRawShader;
  8375. /**
  8376. * Directly creates a webGL program
  8377. * @param vertexCode defines the vertex shader code to use
  8378. * @param fragmentCode defines the fragment shader code to use
  8379. * @param context defines the webGL context to use (if not set, the current one will be used)
  8380. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8381. * @returns the new webGL program
  8382. */
  8383. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8384. /**
  8385. * Creates a webGL program
  8386. * @param vertexCode defines the vertex shader code to use
  8387. * @param fragmentCode defines the fragment shader code to use
  8388. * @param defines defines the string containing the defines to use to compile the shaders
  8389. * @param context defines the webGL context to use (if not set, the current one will be used)
  8390. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8391. * @returns the new webGL program
  8392. */
  8393. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8394. private _createShaderProgram;
  8395. /**
  8396. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8397. * @param shaderProgram defines the webGL program to use
  8398. * @param uniformsNames defines the list of uniform names
  8399. * @returns an array of webGL uniform locations
  8400. */
  8401. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8402. /**
  8403. * Gets the lsit of active attributes for a given webGL program
  8404. * @param shaderProgram defines the webGL program to use
  8405. * @param attributesNames defines the list of attribute names to get
  8406. * @returns an array of indices indicating the offset of each attribute
  8407. */
  8408. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8409. /**
  8410. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8411. * @param effect defines the effect to activate
  8412. */
  8413. enableEffect(effect: Nullable<Effect>): void;
  8414. /**
  8415. * Set the value of an uniform to an array of int32
  8416. * @param uniform defines the webGL uniform location where to store the value
  8417. * @param array defines the array of int32 to store
  8418. */
  8419. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8420. /**
  8421. * Set the value of an uniform to an array of int32 (stored as vec2)
  8422. * @param uniform defines the webGL uniform location where to store the value
  8423. * @param array defines the array of int32 to store
  8424. */
  8425. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8426. /**
  8427. * Set the value of an uniform to an array of int32 (stored as vec3)
  8428. * @param uniform defines the webGL uniform location where to store the value
  8429. * @param array defines the array of int32 to store
  8430. */
  8431. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8432. /**
  8433. * Set the value of an uniform to an array of int32 (stored as vec4)
  8434. * @param uniform defines the webGL uniform location where to store the value
  8435. * @param array defines the array of int32 to store
  8436. */
  8437. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8438. /**
  8439. * Set the value of an uniform to an array of float32
  8440. * @param uniform defines the webGL uniform location where to store the value
  8441. * @param array defines the array of float32 to store
  8442. */
  8443. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8444. /**
  8445. * Set the value of an uniform to an array of float32 (stored as vec2)
  8446. * @param uniform defines the webGL uniform location where to store the value
  8447. * @param array defines the array of float32 to store
  8448. */
  8449. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8450. /**
  8451. * Set the value of an uniform to an array of float32 (stored as vec3)
  8452. * @param uniform defines the webGL uniform location where to store the value
  8453. * @param array defines the array of float32 to store
  8454. */
  8455. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8456. /**
  8457. * Set the value of an uniform to an array of float32 (stored as vec4)
  8458. * @param uniform defines the webGL uniform location where to store the value
  8459. * @param array defines the array of float32 to store
  8460. */
  8461. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8462. /**
  8463. * Set the value of an uniform to an array of number
  8464. * @param uniform defines the webGL uniform location where to store the value
  8465. * @param array defines the array of number to store
  8466. */
  8467. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8468. /**
  8469. * Set the value of an uniform to an array of number (stored as vec2)
  8470. * @param uniform defines the webGL uniform location where to store the value
  8471. * @param array defines the array of number to store
  8472. */
  8473. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8474. /**
  8475. * Set the value of an uniform to an array of number (stored as vec3)
  8476. * @param uniform defines the webGL uniform location where to store the value
  8477. * @param array defines the array of number to store
  8478. */
  8479. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8480. /**
  8481. * Set the value of an uniform to an array of number (stored as vec4)
  8482. * @param uniform defines the webGL uniform location where to store the value
  8483. * @param array defines the array of number to store
  8484. */
  8485. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8486. /**
  8487. * Set the value of an uniform to an array of float32 (stored as matrices)
  8488. * @param uniform defines the webGL uniform location where to store the value
  8489. * @param matrices defines the array of float32 to store
  8490. */
  8491. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8492. /**
  8493. * Set the value of an uniform to a matrix
  8494. * @param uniform defines the webGL uniform location where to store the value
  8495. * @param matrix defines the matrix to store
  8496. */
  8497. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8498. /**
  8499. * Set the value of an uniform to a matrix (3x3)
  8500. * @param uniform defines the webGL uniform location where to store the value
  8501. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8502. */
  8503. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8504. /**
  8505. * Set the value of an uniform to a matrix (2x2)
  8506. * @param uniform defines the webGL uniform location where to store the value
  8507. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8508. */
  8509. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8510. /**
  8511. * Set the value of an uniform to a number (int)
  8512. * @param uniform defines the webGL uniform location where to store the value
  8513. * @param value defines the int number to store
  8514. */
  8515. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8516. /**
  8517. * Set the value of an uniform to a number (float)
  8518. * @param uniform defines the webGL uniform location where to store the value
  8519. * @param value defines the float number to store
  8520. */
  8521. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8522. /**
  8523. * Set the value of an uniform to a vec2
  8524. * @param uniform defines the webGL uniform location where to store the value
  8525. * @param x defines the 1st component of the value
  8526. * @param y defines the 2nd component of the value
  8527. */
  8528. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8529. /**
  8530. * Set the value of an uniform to a vec3
  8531. * @param uniform defines the webGL uniform location where to store the value
  8532. * @param x defines the 1st component of the value
  8533. * @param y defines the 2nd component of the value
  8534. * @param z defines the 3rd component of the value
  8535. */
  8536. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8537. /**
  8538. * Set the value of an uniform to a boolean
  8539. * @param uniform defines the webGL uniform location where to store the value
  8540. * @param bool defines the boolean to store
  8541. */
  8542. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8543. /**
  8544. * Set the value of an uniform to a vec4
  8545. * @param uniform defines the webGL uniform location where to store the value
  8546. * @param x defines the 1st component of the value
  8547. * @param y defines the 2nd component of the value
  8548. * @param z defines the 3rd component of the value
  8549. * @param w defines the 4th component of the value
  8550. */
  8551. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8552. /**
  8553. * Set the value of an uniform to a Color3
  8554. * @param uniform defines the webGL uniform location where to store the value
  8555. * @param color3 defines the color to store
  8556. */
  8557. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8558. /**
  8559. * Set the value of an uniform to a Color3 and an alpha value
  8560. * @param uniform defines the webGL uniform location where to store the value
  8561. * @param color3 defines the color to store
  8562. * @param alpha defines the alpha component to store
  8563. */
  8564. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8565. /**
  8566. * Sets a Color4 on a uniform variable
  8567. * @param uniform defines the uniform location
  8568. * @param color4 defines the value to be set
  8569. */
  8570. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8571. /**
  8572. * Set various states to the webGL context
  8573. * @param culling defines backface culling state
  8574. * @param zOffset defines the value to apply to zOffset (0 by default)
  8575. * @param force defines if states must be applied even if cache is up to date
  8576. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8577. */
  8578. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8579. /**
  8580. * Set the z offset to apply to current rendering
  8581. * @param value defines the offset to apply
  8582. */
  8583. setZOffset(value: number): void;
  8584. /**
  8585. * Gets the current value of the zOffset
  8586. * @returns the current zOffset state
  8587. */
  8588. getZOffset(): number;
  8589. /**
  8590. * Enable or disable depth buffering
  8591. * @param enable defines the state to set
  8592. */
  8593. setDepthBuffer(enable: boolean): void;
  8594. /**
  8595. * Gets a boolean indicating if depth writing is enabled
  8596. * @returns the current depth writing state
  8597. */
  8598. getDepthWrite(): boolean;
  8599. /**
  8600. * Enable or disable depth writing
  8601. * @param enable defines the state to set
  8602. */
  8603. setDepthWrite(enable: boolean): void;
  8604. /**
  8605. * Enable or disable color writing
  8606. * @param enable defines the state to set
  8607. */
  8608. setColorWrite(enable: boolean): void;
  8609. /**
  8610. * Gets a boolean indicating if color writing is enabled
  8611. * @returns the current color writing state
  8612. */
  8613. getColorWrite(): boolean;
  8614. /**
  8615. * Sets alpha constants used by some alpha blending modes
  8616. * @param r defines the red component
  8617. * @param g defines the green component
  8618. * @param b defines the blue component
  8619. * @param a defines the alpha component
  8620. */
  8621. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8622. /**
  8623. * Sets the current alpha mode
  8624. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8625. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8626. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8627. */
  8628. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8629. /**
  8630. * Gets the current alpha mode
  8631. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8632. * @returns the current alpha mode
  8633. */
  8634. getAlphaMode(): number;
  8635. /**
  8636. * Clears the list of texture accessible through engine.
  8637. * This can help preventing texture load conflict due to name collision.
  8638. */
  8639. clearInternalTexturesCache(): void;
  8640. /**
  8641. * Force the entire cache to be cleared
  8642. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8643. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8644. */
  8645. wipeCaches(bruteForce?: boolean): void;
  8646. /**
  8647. * Set the compressed texture format to use, based on the formats you have, and the formats
  8648. * supported by the hardware / browser.
  8649. *
  8650. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8651. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8652. * to API arguments needed to compressed textures. This puts the burden on the container
  8653. * generator to house the arcane code for determining these for current & future formats.
  8654. *
  8655. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8656. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8657. *
  8658. * Note: The result of this call is not taken into account when a texture is base64.
  8659. *
  8660. * @param formatsAvailable defines the list of those format families you have created
  8661. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8662. *
  8663. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8664. * @returns The extension selected.
  8665. */
  8666. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8667. private _getSamplingParameters;
  8668. private _partialLoadImg;
  8669. private _cascadeLoadImgs;
  8670. /** @hidden */
  8671. _createTexture(): WebGLTexture;
  8672. /**
  8673. * Usually called from BABYLON.Texture.ts.
  8674. * Passed information to create a WebGLTexture
  8675. * @param urlArg defines a value which contains one of the following:
  8676. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8677. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8678. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8679. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8680. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8681. * @param scene needed for loading to the correct scene
  8682. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8683. * @param onLoad optional callback to be called upon successful completion
  8684. * @param onError optional callback to be called upon failure
  8685. * @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
  8686. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8687. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8688. * @param forcedExtension defines the extension to use to pick the right loader
  8689. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8690. */
  8691. 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>, forcedExtension?: Nullable<string>): InternalTexture;
  8692. private _rescaleTexture;
  8693. /**
  8694. * Update a raw texture
  8695. * @param texture defines the texture to update
  8696. * @param data defines the data to store in the texture
  8697. * @param format defines the format of the data
  8698. * @param invertY defines if data must be stored with Y axis inverted
  8699. * @param compression defines the compression used (null by default)
  8700. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8701. */
  8702. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8703. /**
  8704. * Creates a raw texture
  8705. * @param data defines the data to store in the texture
  8706. * @param width defines the width of the texture
  8707. * @param height defines the height of the texture
  8708. * @param format defines the format of the data
  8709. * @param generateMipMaps defines if the engine should generate the mip levels
  8710. * @param invertY defines if data must be stored with Y axis inverted
  8711. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8712. * @param compression defines the compression used (null by default)
  8713. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8714. * @returns the raw texture inside an InternalTexture
  8715. */
  8716. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8717. private _unpackFlipYCached;
  8718. /** @hidden */
  8719. _unpackFlipY(value: boolean): void;
  8720. /** @hidden */
  8721. _getUnpackAlignement(): number;
  8722. /**
  8723. * Creates a dynamic texture
  8724. * @param width defines the width of the texture
  8725. * @param height defines the height of the texture
  8726. * @param generateMipMaps defines if the engine should generate the mip levels
  8727. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8728. * @returns the dynamic texture inside an InternalTexture
  8729. */
  8730. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8731. /**
  8732. * Update the sampling mode of a given texture
  8733. * @param samplingMode defines the required sampling mode
  8734. * @param texture defines the texture to update
  8735. */
  8736. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8737. /**
  8738. * Update the content of a dynamic texture
  8739. * @param texture defines the texture to update
  8740. * @param canvas defines the canvas containing the source
  8741. * @param invertY defines if data must be stored with Y axis inverted
  8742. * @param premulAlpha defines if alpha is stored as premultiplied
  8743. * @param format defines the format of the data
  8744. */
  8745. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8746. /**
  8747. * Update a video texture
  8748. * @param texture defines the texture to update
  8749. * @param video defines the video element to use
  8750. * @param invertY defines if data must be stored with Y axis inverted
  8751. */
  8752. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8753. /**
  8754. * Updates a depth texture Comparison Mode and Function.
  8755. * If the comparison Function is equal to 0, the mode will be set to none.
  8756. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8757. * @param texture The texture to set the comparison function for
  8758. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8759. */
  8760. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8761. private _setupDepthStencilTexture;
  8762. /**
  8763. * Creates a depth stencil texture.
  8764. * This is only available in WebGL 2 or with the depth texture extension available.
  8765. * @param size The size of face edge in the texture.
  8766. * @param options The options defining the texture.
  8767. * @returns The texture
  8768. */
  8769. createDepthStencilTexture(size: number | {
  8770. width: number;
  8771. height: number;
  8772. }, options: DepthTextureCreationOptions): InternalTexture;
  8773. /**
  8774. * Creates a depth stencil texture.
  8775. * This is only available in WebGL 2 or with the depth texture extension available.
  8776. * @param size The size of face edge in the texture.
  8777. * @param options The options defining the texture.
  8778. * @returns The texture
  8779. */
  8780. private _createDepthStencilTexture;
  8781. /**
  8782. * Creates a depth stencil cube texture.
  8783. * This is only available in WebGL 2.
  8784. * @param size The size of face edge in the cube texture.
  8785. * @param options The options defining the cube texture.
  8786. * @returns The cube texture
  8787. */
  8788. private _createDepthStencilCubeTexture;
  8789. /**
  8790. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8791. * @param renderTarget The render target to set the frame buffer for
  8792. */
  8793. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8794. /**
  8795. * Creates a new render target texture
  8796. * @param size defines the size of the texture
  8797. * @param options defines the options used to create the texture
  8798. * @returns a new render target texture stored in an InternalTexture
  8799. */
  8800. createRenderTargetTexture(size: number | {
  8801. width: number;
  8802. height: number;
  8803. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8804. /**
  8805. * Create a multi render target texture
  8806. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8807. * @param size defines the size of the texture
  8808. * @param options defines the creation options
  8809. * @returns the cube texture as an InternalTexture
  8810. */
  8811. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8812. private _setupFramebufferDepthAttachments;
  8813. /**
  8814. * Updates the sample count of a render target texture
  8815. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8816. * @param texture defines the texture to update
  8817. * @param samples defines the sample count to set
  8818. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8819. */
  8820. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8821. /**
  8822. * Update the sample count for a given multiple render target texture
  8823. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8824. * @param textures defines the textures to update
  8825. * @param samples defines the sample count to set
  8826. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8827. */
  8828. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8829. /** @hidden */
  8830. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8831. /** @hidden */
  8832. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8833. /** @hidden */
  8834. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8835. /** @hidden */
  8836. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8837. /**
  8838. * Creates a new render target cube texture
  8839. * @param size defines the size of the texture
  8840. * @param options defines the options used to create the texture
  8841. * @returns a new render target cube texture stored in an InternalTexture
  8842. */
  8843. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8844. /**
  8845. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8846. * @param rootUrl defines the url where the file to load is located
  8847. * @param scene defines the current scene
  8848. * @param lodScale defines scale to apply to the mip map selection
  8849. * @param lodOffset defines offset to apply to the mip map selection
  8850. * @param onLoad defines an optional callback raised when the texture is loaded
  8851. * @param onError defines an optional callback raised if there is an issue to load the texture
  8852. * @param format defines the format of the data
  8853. * @param forcedExtension defines the extension to use to pick the right loader
  8854. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8855. * @returns the cube texture as an InternalTexture
  8856. */
  8857. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8858. /**
  8859. * Creates a cube texture
  8860. * @param rootUrl defines the url where the files to load is located
  8861. * @param scene defines the current scene
  8862. * @param files defines the list of files to load (1 per face)
  8863. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8864. * @param onLoad defines an optional callback raised when the texture is loaded
  8865. * @param onError defines an optional callback raised if there is an issue to load the texture
  8866. * @param format defines the format of the data
  8867. * @param forcedExtension defines the extension to use to pick the right loader
  8868. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8869. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8870. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8871. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8872. * @returns the cube texture as an InternalTexture
  8873. */
  8874. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  8875. /**
  8876. * @hidden
  8877. */
  8878. _setCubeMapTextureParams(loadMipmap: boolean): void;
  8879. /**
  8880. * Update a raw cube texture
  8881. * @param texture defines the texture to udpdate
  8882. * @param data defines the data to store
  8883. * @param format defines the data format
  8884. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8885. * @param invertY defines if data must be stored with Y axis inverted
  8886. * @param compression defines the compression used (null by default)
  8887. * @param level defines which level of the texture to update
  8888. */
  8889. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8890. /**
  8891. * Creates a new raw cube texture
  8892. * @param data defines the array of data to use to create each face
  8893. * @param size defines the size of the textures
  8894. * @param format defines the format of the data
  8895. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8896. * @param generateMipMaps defines if the engine should generate the mip levels
  8897. * @param invertY defines if data must be stored with Y axis inverted
  8898. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8899. * @param compression defines the compression used (null by default)
  8900. * @returns the cube texture as an InternalTexture
  8901. */
  8902. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8903. /**
  8904. * Creates a new raw cube texture from a specified url
  8905. * @param url defines the url where the data is located
  8906. * @param scene defines the current scene
  8907. * @param size defines the size of the textures
  8908. * @param format defines the format of the data
  8909. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8910. * @param noMipmap defines if the engine should avoid generating the mip levels
  8911. * @param callback defines a callback used to extract texture data from loaded data
  8912. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8913. * @param onLoad defines a callback called when texture is loaded
  8914. * @param onError defines a callback called if there is an error
  8915. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8916. * @param invertY defines if data must be stored with Y axis inverted
  8917. * @returns the cube texture as an InternalTexture
  8918. */
  8919. 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;
  8920. /**
  8921. * Update a raw 3D texture
  8922. * @param texture defines the texture to update
  8923. * @param data defines the data to store
  8924. * @param format defines the data format
  8925. * @param invertY defines if data must be stored with Y axis inverted
  8926. * @param compression defines the used compression (can be null)
  8927. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8928. */
  8929. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8930. /**
  8931. * Creates a new raw 3D texture
  8932. * @param data defines the data used to create the texture
  8933. * @param width defines the width of the texture
  8934. * @param height defines the height of the texture
  8935. * @param depth defines the depth of the texture
  8936. * @param format defines the format of the texture
  8937. * @param generateMipMaps defines if the engine must generate mip levels
  8938. * @param invertY defines if data must be stored with Y axis inverted
  8939. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8940. * @param compression defines the compressed used (can be null)
  8941. * @param textureType defines the compressed used (can be null)
  8942. * @returns a new raw 3D texture (stored in an InternalTexture)
  8943. */
  8944. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8945. private _prepareWebGLTextureContinuation;
  8946. private _prepareWebGLTexture;
  8947. private _convertRGBtoRGBATextureData;
  8948. /** @hidden */
  8949. _releaseFramebufferObjects(texture: InternalTexture): void;
  8950. /** @hidden */
  8951. _releaseTexture(texture: InternalTexture): void;
  8952. private setProgram;
  8953. private _boundUniforms;
  8954. /**
  8955. * Binds an effect to the webGL context
  8956. * @param effect defines the effect to bind
  8957. */
  8958. bindSamplers(effect: Effect): void;
  8959. private _moveBoundTextureOnTop;
  8960. private _getCorrectTextureChannel;
  8961. private _linkTrackers;
  8962. private _removeDesignatedSlot;
  8963. private _activateCurrentTexture;
  8964. /** @hidden */
  8965. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8966. /** @hidden */
  8967. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8968. /**
  8969. * Sets a texture to the webGL context from a postprocess
  8970. * @param channel defines the channel to use
  8971. * @param postProcess defines the source postprocess
  8972. */
  8973. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8974. /**
  8975. * Binds the output of the passed in post process to the texture channel specified
  8976. * @param channel The channel the texture should be bound to
  8977. * @param postProcess The post process which's output should be bound
  8978. */
  8979. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8980. /**
  8981. * Unbind all textures from the webGL context
  8982. */
  8983. unbindAllTextures(): void;
  8984. /**
  8985. * Sets a texture to the according uniform.
  8986. * @param channel The texture channel
  8987. * @param uniform The uniform to set
  8988. * @param texture The texture to apply
  8989. */
  8990. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8991. /**
  8992. * Sets a depth stencil texture from a render target to the according uniform.
  8993. * @param channel The texture channel
  8994. * @param uniform The uniform to set
  8995. * @param texture The render target texture containing the depth stencil texture to apply
  8996. */
  8997. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8998. private _bindSamplerUniformToChannel;
  8999. private _getTextureWrapMode;
  9000. private _setTexture;
  9001. /**
  9002. * Sets an array of texture to the webGL context
  9003. * @param channel defines the channel where the texture array must be set
  9004. * @param uniform defines the associated uniform location
  9005. * @param textures defines the array of textures to bind
  9006. */
  9007. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  9008. /** @hidden */
  9009. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  9010. private _setTextureParameterFloat;
  9011. private _setTextureParameterInteger;
  9012. /**
  9013. * Reads pixels from the current frame buffer. Please note that this function can be slow
  9014. * @param x defines the x coordinate of the rectangle where pixels must be read
  9015. * @param y defines the y coordinate of the rectangle where pixels must be read
  9016. * @param width defines the width of the rectangle where pixels must be read
  9017. * @param height defines the height of the rectangle where pixels must be read
  9018. * @returns a Uint8Array containing RGBA colors
  9019. */
  9020. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  9021. /**
  9022. * Add an externaly attached data from its key.
  9023. * This method call will fail and return false, if such key already exists.
  9024. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  9025. * @param key the unique key that identifies the data
  9026. * @param data the data object to associate to the key for this Engine instance
  9027. * @return true if no such key were already present and the data was added successfully, false otherwise
  9028. */
  9029. addExternalData<T>(key: string, data: T): boolean;
  9030. /**
  9031. * Get an externaly attached data from its key
  9032. * @param key the unique key that identifies the data
  9033. * @return the associated data, if present (can be null), or undefined if not present
  9034. */
  9035. getExternalData<T>(key: string): T;
  9036. /**
  9037. * Get an externaly attached data from its key, create it using a factory if it's not already present
  9038. * @param key the unique key that identifies the data
  9039. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  9040. * @return the associated data, can be null if the factory returned null.
  9041. */
  9042. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  9043. /**
  9044. * Remove an externaly attached data from the Engine instance
  9045. * @param key the unique key that identifies the data
  9046. * @return true if the data was successfully removed, false if it doesn't exist
  9047. */
  9048. removeExternalData(key: string): boolean;
  9049. /**
  9050. * Unbind all vertex attributes from the webGL context
  9051. */
  9052. unbindAllAttributes(): void;
  9053. /**
  9054. * 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
  9055. */
  9056. releaseEffects(): void;
  9057. /**
  9058. * Dispose and release all associated resources
  9059. */
  9060. dispose(): void;
  9061. /**
  9062. * Display the loading screen
  9063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9064. */
  9065. displayLoadingUI(): void;
  9066. /**
  9067. * Hide the loading screen
  9068. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9069. */
  9070. hideLoadingUI(): void;
  9071. /**
  9072. * Gets the current loading screen object
  9073. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9074. */
  9075. /**
  9076. * Sets the current loading screen object
  9077. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9078. */
  9079. loadingScreen: ILoadingScreen;
  9080. /**
  9081. * Sets the current loading screen text
  9082. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9083. */
  9084. loadingUIText: string;
  9085. /**
  9086. * Sets the current loading screen background color
  9087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9088. */
  9089. loadingUIBackgroundColor: string;
  9090. /**
  9091. * Attach a new callback raised when context lost event is fired
  9092. * @param callback defines the callback to call
  9093. */
  9094. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9095. /**
  9096. * Attach a new callback raised when context restored event is fired
  9097. * @param callback defines the callback to call
  9098. */
  9099. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9100. /**
  9101. * Gets the source code of the vertex shader associated with a specific webGL program
  9102. * @param program defines the program to use
  9103. * @returns a string containing the source code of the vertex shader associated with the program
  9104. */
  9105. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9106. /**
  9107. * Gets the source code of the fragment shader associated with a specific webGL program
  9108. * @param program defines the program to use
  9109. * @returns a string containing the source code of the fragment shader associated with the program
  9110. */
  9111. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9112. /**
  9113. * Get the current error code of the webGL context
  9114. * @returns the error code
  9115. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9116. */
  9117. getError(): number;
  9118. /**
  9119. * Gets the current framerate
  9120. * @returns a number representing the framerate
  9121. */
  9122. getFps(): number;
  9123. /**
  9124. * Gets the time spent between current and previous frame
  9125. * @returns a number representing the delta time in ms
  9126. */
  9127. getDeltaTime(): number;
  9128. private _measureFps;
  9129. /** @hidden */
  9130. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9131. private _canRenderToFloatFramebuffer;
  9132. private _canRenderToHalfFloatFramebuffer;
  9133. private _canRenderToFramebuffer;
  9134. /** @hidden */
  9135. _getWebGLTextureType(type: number): number;
  9136. private _getInternalFormat;
  9137. /** @hidden */
  9138. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9139. /** @hidden */
  9140. _getRGBAMultiSampleBufferFormat(type: number): number;
  9141. /** @hidden */
  9142. _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;
  9143. /** @hidden */
  9144. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9145. private _partialLoadFile;
  9146. private _cascadeLoadFiles;
  9147. /**
  9148. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9149. * @returns true if the engine can be created
  9150. * @ignorenaming
  9151. */
  9152. static isSupported(): boolean;
  9153. }
  9154. }
  9155. declare module BABYLON {
  9156. class NullEngineOptions {
  9157. renderWidth: number;
  9158. renderHeight: number;
  9159. textureSize: number;
  9160. deterministicLockstep: boolean;
  9161. lockstepMaxSteps: number;
  9162. }
  9163. /**
  9164. * The null engine class provides support for headless version of babylon.js.
  9165. * This can be used in server side scenario or for testing purposes
  9166. */
  9167. class NullEngine extends Engine {
  9168. private _options;
  9169. isDeterministicLockStep(): boolean;
  9170. getLockstepMaxSteps(): number;
  9171. getHardwareScalingLevel(): number;
  9172. constructor(options?: NullEngineOptions);
  9173. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9174. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9175. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9176. getRenderWidth(useScreen?: boolean): number;
  9177. getRenderHeight(useScreen?: boolean): number;
  9178. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9179. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9180. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9181. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9182. bindSamplers(effect: Effect): void;
  9183. enableEffect(effect: Effect): void;
  9184. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9185. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9186. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9187. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9188. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9189. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9190. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9191. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9192. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9193. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9194. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9195. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9196. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9197. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9198. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9199. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9200. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9201. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9202. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9203. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9204. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9205. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9206. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9207. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9208. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9209. bindBuffers(vertexBuffers: {
  9210. [key: string]: VertexBuffer;
  9211. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9212. wipeCaches(bruteForce?: boolean): void;
  9213. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9214. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9215. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9216. _createTexture(): WebGLTexture;
  9217. _releaseTexture(texture: InternalTexture): void;
  9218. 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;
  9219. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9220. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9221. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9222. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9223. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9224. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9225. /**
  9226. * Get the current error code of the webGL context
  9227. * @returns the error code
  9228. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9229. */
  9230. getError(): number;
  9231. /** @hidden */
  9232. _getUnpackAlignement(): number;
  9233. /** @hidden */
  9234. _unpackFlipY(value: boolean): void;
  9235. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9236. /**
  9237. * Updates a dynamic vertex buffer.
  9238. * @param vertexBuffer the vertex buffer to update
  9239. * @param data the data used to update the vertex buffer
  9240. * @param byteOffset the byte offset of the data (optional)
  9241. * @param byteLength the byte length of the data (optional)
  9242. */
  9243. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9244. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9245. _bindTexture(channel: number, texture: InternalTexture): void;
  9246. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9247. releaseEffects(): void;
  9248. displayLoadingUI(): void;
  9249. hideLoadingUI(): void;
  9250. /** @hidden */
  9251. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9252. /** @hidden */
  9253. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9254. /** @hidden */
  9255. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9256. /** @hidden */
  9257. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9258. }
  9259. }
  9260. interface WebGLRenderingContext {
  9261. readonly RASTERIZER_DISCARD: number;
  9262. readonly DEPTH_COMPONENT24: number;
  9263. readonly TEXTURE_3D: number;
  9264. readonly TEXTURE_2D_ARRAY: number;
  9265. readonly TEXTURE_COMPARE_FUNC: number;
  9266. readonly TEXTURE_COMPARE_MODE: number;
  9267. readonly COMPARE_REF_TO_TEXTURE: number;
  9268. readonly TEXTURE_WRAP_R: number;
  9269. readonly HALF_FLOAT: number;
  9270. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9271. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9272. 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;
  9273. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9274. readonly TRANSFORM_FEEDBACK: number;
  9275. readonly INTERLEAVED_ATTRIBS: number;
  9276. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9277. createTransformFeedback(): WebGLTransformFeedback;
  9278. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9279. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9280. beginTransformFeedback(primitiveMode: number): void;
  9281. endTransformFeedback(): void;
  9282. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9283. }
  9284. interface ImageBitmap {
  9285. readonly width: number;
  9286. readonly height: number;
  9287. close(): void;
  9288. }
  9289. interface WebGLQuery extends WebGLObject {
  9290. }
  9291. declare var WebGLQuery: {
  9292. prototype: WebGLQuery;
  9293. new (): WebGLQuery;
  9294. };
  9295. interface WebGLSampler extends WebGLObject {
  9296. }
  9297. declare var WebGLSampler: {
  9298. prototype: WebGLSampler;
  9299. new (): WebGLSampler;
  9300. };
  9301. interface WebGLSync extends WebGLObject {
  9302. }
  9303. declare var WebGLSync: {
  9304. prototype: WebGLSync;
  9305. new (): WebGLSync;
  9306. };
  9307. interface WebGLTransformFeedback extends WebGLObject {
  9308. }
  9309. declare var WebGLTransformFeedback: {
  9310. prototype: WebGLTransformFeedback;
  9311. new (): WebGLTransformFeedback;
  9312. };
  9313. interface WebGLVertexArrayObject extends WebGLObject {
  9314. }
  9315. declare var WebGLVertexArrayObject: {
  9316. prototype: WebGLVertexArrayObject;
  9317. new (): WebGLVertexArrayObject;
  9318. };
  9319. declare module BABYLON {
  9320. class KeyboardEventTypes {
  9321. static _KEYDOWN: number;
  9322. static _KEYUP: number;
  9323. static readonly KEYDOWN: number;
  9324. static readonly KEYUP: number;
  9325. }
  9326. class KeyboardInfo {
  9327. type: number;
  9328. event: KeyboardEvent;
  9329. constructor(type: number, event: KeyboardEvent);
  9330. }
  9331. /**
  9332. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9333. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9334. */
  9335. class KeyboardInfoPre extends KeyboardInfo {
  9336. constructor(type: number, event: KeyboardEvent);
  9337. skipOnPointerObservable: boolean;
  9338. }
  9339. }
  9340. declare module BABYLON {
  9341. class PointerEventTypes {
  9342. static _POINTERDOWN: number;
  9343. static _POINTERUP: number;
  9344. static _POINTERMOVE: number;
  9345. static _POINTERWHEEL: number;
  9346. static _POINTERPICK: number;
  9347. static _POINTERTAP: number;
  9348. static _POINTERDOUBLETAP: number;
  9349. static readonly POINTERDOWN: number;
  9350. static readonly POINTERUP: number;
  9351. static readonly POINTERMOVE: number;
  9352. static readonly POINTERWHEEL: number;
  9353. static readonly POINTERPICK: number;
  9354. static readonly POINTERTAP: number;
  9355. static readonly POINTERDOUBLETAP: number;
  9356. }
  9357. class PointerInfoBase {
  9358. type: number;
  9359. event: PointerEvent | MouseWheelEvent;
  9360. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9361. }
  9362. /**
  9363. * This class is used to store pointer related info for the onPrePointerObservable event.
  9364. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9365. */
  9366. class PointerInfoPre extends PointerInfoBase {
  9367. /**
  9368. * Ray from a pointer if availible (eg. 6dof controller)
  9369. */
  9370. ray: Nullable<Ray>;
  9371. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9372. localPosition: Vector2;
  9373. skipOnPointerObservable: boolean;
  9374. }
  9375. /**
  9376. * This type contains all the data related to a pointer event in Babylon.js.
  9377. * 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.
  9378. */
  9379. class PointerInfo extends PointerInfoBase {
  9380. pickInfo: Nullable<PickingInfo>;
  9381. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9382. }
  9383. }
  9384. declare module BABYLON {
  9385. class StickValues {
  9386. x: number;
  9387. y: number;
  9388. constructor(x: number, y: number);
  9389. }
  9390. interface GamepadButtonChanges {
  9391. changed: boolean;
  9392. pressChanged: boolean;
  9393. touchChanged: boolean;
  9394. valueChanged: boolean;
  9395. }
  9396. class Gamepad {
  9397. id: string;
  9398. index: number;
  9399. browserGamepad: any;
  9400. type: number;
  9401. private _leftStick;
  9402. private _rightStick;
  9403. _isConnected: boolean;
  9404. private _leftStickAxisX;
  9405. private _leftStickAxisY;
  9406. private _rightStickAxisX;
  9407. private _rightStickAxisY;
  9408. private _onleftstickchanged;
  9409. private _onrightstickchanged;
  9410. static GAMEPAD: number;
  9411. static GENERIC: number;
  9412. static XBOX: number;
  9413. static POSE_ENABLED: number;
  9414. protected _invertLeftStickY: boolean;
  9415. readonly isConnected: boolean;
  9416. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9417. onleftstickchanged(callback: (values: StickValues) => void): void;
  9418. onrightstickchanged(callback: (values: StickValues) => void): void;
  9419. leftStick: StickValues;
  9420. rightStick: StickValues;
  9421. update(): void;
  9422. dispose(): void;
  9423. }
  9424. class GenericPad extends Gamepad {
  9425. private _buttons;
  9426. private _onbuttondown;
  9427. private _onbuttonup;
  9428. onButtonDownObservable: Observable<number>;
  9429. onButtonUpObservable: Observable<number>;
  9430. onbuttondown(callback: (buttonPressed: number) => void): void;
  9431. onbuttonup(callback: (buttonReleased: number) => void): void;
  9432. constructor(id: string, index: number, browserGamepad: any);
  9433. private _setButtonValue;
  9434. update(): void;
  9435. dispose(): void;
  9436. }
  9437. }
  9438. declare module BABYLON {
  9439. class GamepadManager {
  9440. private _scene?;
  9441. private _babylonGamepads;
  9442. private _oneGamepadConnected;
  9443. _isMonitoring: boolean;
  9444. private _gamepadEventSupported;
  9445. private _gamepadSupport;
  9446. onGamepadConnectedObservable: Observable<Gamepad>;
  9447. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9448. private _onGamepadConnectedEvent;
  9449. private _onGamepadDisconnectedEvent;
  9450. constructor(_scene?: Scene | undefined);
  9451. readonly gamepads: Gamepad[];
  9452. getGamepadByType(type?: number): Nullable<Gamepad>;
  9453. dispose(): void;
  9454. private _addNewGamepad;
  9455. private _startMonitoringGamepads;
  9456. private _stopMonitoringGamepads;
  9457. _checkGamepadsStatus(): void;
  9458. private _updateGamepadObjects;
  9459. }
  9460. }
  9461. declare module BABYLON {
  9462. interface Scene {
  9463. /** @hidden */
  9464. _gamepadManager: Nullable<GamepadManager>;
  9465. /**
  9466. * Gets the gamepad manager associated with the scene
  9467. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9468. */
  9469. gamepadManager: GamepadManager;
  9470. }
  9471. interface FreeCameraInputsManager {
  9472. addGamepad(): FreeCameraInputsManager;
  9473. }
  9474. interface ArcRotateCameraInputsManager {
  9475. addGamepad(): ArcRotateCameraInputsManager;
  9476. }
  9477. /**
  9478. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9479. */
  9480. class GamepadSystemSceneComponent implements ISceneComponent {
  9481. /**
  9482. * The component name helpfull to identify the component in the list of scene components.
  9483. */
  9484. readonly name: string;
  9485. /**
  9486. * The scene the component belongs to.
  9487. */
  9488. scene: Scene;
  9489. /**
  9490. * Creates a new instance of the component for the given scene
  9491. * @param scene Defines the scene to register the component in
  9492. */
  9493. constructor(scene: Scene);
  9494. /**
  9495. * Registers the component in a given scene
  9496. */
  9497. register(): void;
  9498. /**
  9499. * Rebuilds the elements related to this component in case of
  9500. * context lost for instance.
  9501. */
  9502. rebuild(): void;
  9503. /**
  9504. * Disposes the component and the associated ressources
  9505. */
  9506. dispose(): void;
  9507. private _beforeCameraUpdate;
  9508. }
  9509. }
  9510. declare module BABYLON {
  9511. /**
  9512. * Defines supported buttons for XBox360 compatible gamepads
  9513. */
  9514. enum Xbox360Button {
  9515. /** A */
  9516. A = 0,
  9517. /** B */
  9518. B = 1,
  9519. /** X */
  9520. X = 2,
  9521. /** Y */
  9522. Y = 3,
  9523. /** Start */
  9524. Start = 4,
  9525. /** Back */
  9526. Back = 5,
  9527. /** Left button */
  9528. LB = 6,
  9529. /** Right button */
  9530. RB = 7,
  9531. /** Left stick */
  9532. LeftStick = 8,
  9533. /** Right stick */
  9534. RightStick = 9
  9535. }
  9536. /** Defines values for XBox360 DPad */
  9537. enum Xbox360Dpad {
  9538. /** Up */
  9539. Up = 0,
  9540. /** Down */
  9541. Down = 1,
  9542. /** Left */
  9543. Left = 2,
  9544. /** Right */
  9545. Right = 3
  9546. }
  9547. /**
  9548. * Defines a XBox360 gamepad
  9549. */
  9550. class Xbox360Pad extends Gamepad {
  9551. private _leftTrigger;
  9552. private _rightTrigger;
  9553. private _onlefttriggerchanged;
  9554. private _onrighttriggerchanged;
  9555. private _onbuttondown;
  9556. private _onbuttonup;
  9557. private _ondpaddown;
  9558. private _ondpadup;
  9559. /** Observable raised when a button is pressed */
  9560. onButtonDownObservable: Observable<Xbox360Button>;
  9561. /** Observable raised when a button is released */
  9562. onButtonUpObservable: Observable<Xbox360Button>;
  9563. /** Observable raised when a pad is pressed */
  9564. onPadDownObservable: Observable<Xbox360Dpad>;
  9565. /** Observable raised when a pad is released */
  9566. onPadUpObservable: Observable<Xbox360Dpad>;
  9567. private _buttonA;
  9568. private _buttonB;
  9569. private _buttonX;
  9570. private _buttonY;
  9571. private _buttonBack;
  9572. private _buttonStart;
  9573. private _buttonLB;
  9574. private _buttonRB;
  9575. private _buttonLeftStick;
  9576. private _buttonRightStick;
  9577. private _dPadUp;
  9578. private _dPadDown;
  9579. private _dPadLeft;
  9580. private _dPadRight;
  9581. private _isXboxOnePad;
  9582. /**
  9583. * Creates a new XBox360 gamepad object
  9584. * @param id defines the id of this gamepad
  9585. * @param index defines its index
  9586. * @param gamepad defines the internal HTML gamepad object
  9587. * @param xboxOne defines if it is a XBox One gamepad
  9588. */
  9589. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9590. /**
  9591. * Defines the callback to call when left trigger is pressed
  9592. * @param callback defines the callback to use
  9593. */
  9594. onlefttriggerchanged(callback: (value: number) => void): void;
  9595. /**
  9596. * Defines the callback to call when right trigger is pressed
  9597. * @param callback defines the callback to use
  9598. */
  9599. onrighttriggerchanged(callback: (value: number) => void): void;
  9600. /**
  9601. * Gets or sets left trigger value
  9602. */
  9603. leftTrigger: number;
  9604. /**
  9605. * Gets or sets right trigger value
  9606. */
  9607. rightTrigger: number;
  9608. /**
  9609. * Defines the callback to call when a button is pressed
  9610. * @param callback defines the callback to use
  9611. */
  9612. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9613. /**
  9614. * Defines the callback to call when a button is released
  9615. * @param callback defines the callback to use
  9616. */
  9617. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9618. /**
  9619. * Defines the callback to call when a pad is pressed
  9620. * @param callback defines the callback to use
  9621. */
  9622. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9623. /**
  9624. * Defines the callback to call when a pad is released
  9625. * @param callback defines the callback to use
  9626. */
  9627. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9628. private _setButtonValue;
  9629. private _setDPadValue;
  9630. /** Gets or sets value of A button */
  9631. buttonA: number;
  9632. /** Gets or sets value of B button */
  9633. buttonB: number;
  9634. /** Gets or sets value of X button */
  9635. buttonX: number;
  9636. /** Gets or sets value of Y button */
  9637. buttonY: number;
  9638. /** Gets or sets value of Start button */
  9639. buttonStart: number;
  9640. /** Gets or sets value of Back button */
  9641. buttonBack: number;
  9642. /** Gets or sets value of Left button */
  9643. buttonLB: number;
  9644. /** Gets or sets value of Right button */
  9645. buttonRB: number;
  9646. /** Gets or sets value of left stick */
  9647. buttonLeftStick: number;
  9648. /** Gets or sets value of right stick */
  9649. buttonRightStick: number;
  9650. /** Gets or sets value of DPad up */
  9651. dPadUp: number;
  9652. /** Gets or sets value of DPad down */
  9653. dPadDown: number;
  9654. /** Gets or sets value of DPad left */
  9655. dPadLeft: number;
  9656. /** Gets or sets value of DPad right */
  9657. dPadRight: number;
  9658. /**
  9659. * Force the gamepad to synchronize with device values
  9660. */
  9661. update(): void;
  9662. dispose(): void;
  9663. }
  9664. }
  9665. declare module BABYLON {
  9666. /**
  9667. * Represents the different options available during the creation of
  9668. * a Environment helper.
  9669. *
  9670. * This can control the default ground, skybox and image processing setup of your scene.
  9671. */
  9672. interface IEnvironmentHelperOptions {
  9673. /**
  9674. * Specifies wether or not to create a ground.
  9675. * True by default.
  9676. */
  9677. createGround: boolean;
  9678. /**
  9679. * Specifies the ground size.
  9680. * 15 by default.
  9681. */
  9682. groundSize: number;
  9683. /**
  9684. * The texture used on the ground for the main color.
  9685. * Comes from the BabylonJS CDN by default.
  9686. *
  9687. * Remarks: Can be either a texture or a url.
  9688. */
  9689. groundTexture: string | BaseTexture;
  9690. /**
  9691. * The color mixed in the ground texture by default.
  9692. * BabylonJS clearColor by default.
  9693. */
  9694. groundColor: Color3;
  9695. /**
  9696. * Specifies the ground opacity.
  9697. * 1 by default.
  9698. */
  9699. groundOpacity: number;
  9700. /**
  9701. * Enables the ground to receive shadows.
  9702. * True by default.
  9703. */
  9704. enableGroundShadow: boolean;
  9705. /**
  9706. * Helps preventing the shadow to be fully black on the ground.
  9707. * 0.5 by default.
  9708. */
  9709. groundShadowLevel: number;
  9710. /**
  9711. * Creates a mirror texture attach to the ground.
  9712. * false by default.
  9713. */
  9714. enableGroundMirror: boolean;
  9715. /**
  9716. * Specifies the ground mirror size ratio.
  9717. * 0.3 by default as the default kernel is 64.
  9718. */
  9719. groundMirrorSizeRatio: number;
  9720. /**
  9721. * Specifies the ground mirror blur kernel size.
  9722. * 64 by default.
  9723. */
  9724. groundMirrorBlurKernel: number;
  9725. /**
  9726. * Specifies the ground mirror visibility amount.
  9727. * 1 by default
  9728. */
  9729. groundMirrorAmount: number;
  9730. /**
  9731. * Specifies the ground mirror reflectance weight.
  9732. * This uses the standard weight of the background material to setup the fresnel effect
  9733. * of the mirror.
  9734. * 1 by default.
  9735. */
  9736. groundMirrorFresnelWeight: number;
  9737. /**
  9738. * Specifies the ground mirror Falloff distance.
  9739. * This can helps reducing the size of the reflection.
  9740. * 0 by Default.
  9741. */
  9742. groundMirrorFallOffDistance: number;
  9743. /**
  9744. * Specifies the ground mirror texture type.
  9745. * Unsigned Int by Default.
  9746. */
  9747. groundMirrorTextureType: number;
  9748. /**
  9749. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  9750. * the shown objects.
  9751. */
  9752. groundYBias: number;
  9753. /**
  9754. * Specifies wether or not to create a skybox.
  9755. * True by default.
  9756. */
  9757. createSkybox: boolean;
  9758. /**
  9759. * Specifies the skybox size.
  9760. * 20 by default.
  9761. */
  9762. skyboxSize: number;
  9763. /**
  9764. * The texture used on the skybox for the main color.
  9765. * Comes from the BabylonJS CDN by default.
  9766. *
  9767. * Remarks: Can be either a texture or a url.
  9768. */
  9769. skyboxTexture: string | BaseTexture;
  9770. /**
  9771. * The color mixed in the skybox texture by default.
  9772. * BabylonJS clearColor by default.
  9773. */
  9774. skyboxColor: Color3;
  9775. /**
  9776. * The background rotation around the Y axis of the scene.
  9777. * This helps aligning the key lights of your scene with the background.
  9778. * 0 by default.
  9779. */
  9780. backgroundYRotation: number;
  9781. /**
  9782. * Compute automatically the size of the elements to best fit with the scene.
  9783. */
  9784. sizeAuto: boolean;
  9785. /**
  9786. * Default position of the rootMesh if autoSize is not true.
  9787. */
  9788. rootPosition: Vector3;
  9789. /**
  9790. * Sets up the image processing in the scene.
  9791. * true by default.
  9792. */
  9793. setupImageProcessing: boolean;
  9794. /**
  9795. * The texture used as your environment texture in the scene.
  9796. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9797. *
  9798. * Remarks: Can be either a texture or a url.
  9799. */
  9800. environmentTexture: string | BaseTexture;
  9801. /**
  9802. * The value of the exposure to apply to the scene.
  9803. * 0.6 by default if setupImageProcessing is true.
  9804. */
  9805. cameraExposure: number;
  9806. /**
  9807. * The value of the contrast to apply to the scene.
  9808. * 1.6 by default if setupImageProcessing is true.
  9809. */
  9810. cameraContrast: number;
  9811. /**
  9812. * Specifies wether or not tonemapping should be enabled in the scene.
  9813. * true by default if setupImageProcessing is true.
  9814. */
  9815. toneMappingEnabled: boolean;
  9816. }
  9817. /**
  9818. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9819. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9820. * It also helps with the default setup of your imageProcessing configuration.
  9821. */
  9822. class EnvironmentHelper {
  9823. /**
  9824. * Default ground texture URL.
  9825. */
  9826. private static _groundTextureCDNUrl;
  9827. /**
  9828. * Default skybox texture URL.
  9829. */
  9830. private static _skyboxTextureCDNUrl;
  9831. /**
  9832. * Default environment texture URL.
  9833. */
  9834. private static _environmentTextureCDNUrl;
  9835. /**
  9836. * Creates the default options for the helper.
  9837. */
  9838. private static _getDefaultOptions;
  9839. private _rootMesh;
  9840. /**
  9841. * Gets the root mesh created by the helper.
  9842. */
  9843. readonly rootMesh: Mesh;
  9844. private _skybox;
  9845. /**
  9846. * Gets the skybox created by the helper.
  9847. */
  9848. readonly skybox: Nullable<Mesh>;
  9849. private _skyboxTexture;
  9850. /**
  9851. * Gets the skybox texture created by the helper.
  9852. */
  9853. readonly skyboxTexture: Nullable<BaseTexture>;
  9854. private _skyboxMaterial;
  9855. /**
  9856. * Gets the skybox material created by the helper.
  9857. */
  9858. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9859. private _ground;
  9860. /**
  9861. * Gets the ground mesh created by the helper.
  9862. */
  9863. readonly ground: Nullable<Mesh>;
  9864. private _groundTexture;
  9865. /**
  9866. * Gets the ground texture created by the helper.
  9867. */
  9868. readonly groundTexture: Nullable<BaseTexture>;
  9869. private _groundMirror;
  9870. /**
  9871. * Gets the ground mirror created by the helper.
  9872. */
  9873. readonly groundMirror: Nullable<MirrorTexture>;
  9874. /**
  9875. * Gets the ground mirror render list to helps pushing the meshes
  9876. * you wish in the ground reflection.
  9877. */
  9878. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9879. private _groundMaterial;
  9880. /**
  9881. * Gets the ground material created by the helper.
  9882. */
  9883. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9884. /**
  9885. * Stores the creation options.
  9886. */
  9887. private readonly _scene;
  9888. private _options;
  9889. /**
  9890. * This observable will be notified with any error during the creation of the environment,
  9891. * mainly texture creation errors.
  9892. */
  9893. onErrorObservable: Observable<{
  9894. message?: string;
  9895. exception?: any;
  9896. }>;
  9897. /**
  9898. * constructor
  9899. * @param options
  9900. * @param scene The scene to add the material to
  9901. */
  9902. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9903. /**
  9904. * Updates the background according to the new options
  9905. * @param options
  9906. */
  9907. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9908. /**
  9909. * Sets the primary color of all the available elements.
  9910. * @param color the main color to affect to the ground and the background
  9911. */
  9912. setMainColor(color: Color3): void;
  9913. /**
  9914. * Setup the image processing according to the specified options.
  9915. */
  9916. private _setupImageProcessing;
  9917. /**
  9918. * Setup the environment texture according to the specified options.
  9919. */
  9920. private _setupEnvironmentTexture;
  9921. /**
  9922. * Setup the background according to the specified options.
  9923. */
  9924. private _setupBackground;
  9925. /**
  9926. * Get the scene sizes according to the setup.
  9927. */
  9928. private _getSceneSize;
  9929. /**
  9930. * Setup the ground according to the specified options.
  9931. */
  9932. private _setupGround;
  9933. /**
  9934. * Setup the ground material according to the specified options.
  9935. */
  9936. private _setupGroundMaterial;
  9937. /**
  9938. * Setup the ground diffuse texture according to the specified options.
  9939. */
  9940. private _setupGroundDiffuseTexture;
  9941. /**
  9942. * Setup the ground mirror texture according to the specified options.
  9943. */
  9944. private _setupGroundMirrorTexture;
  9945. /**
  9946. * Setup the ground to receive the mirror texture.
  9947. */
  9948. private _setupMirrorInGroundMaterial;
  9949. /**
  9950. * Setup the skybox according to the specified options.
  9951. */
  9952. private _setupSkybox;
  9953. /**
  9954. * Setup the skybox material according to the specified options.
  9955. */
  9956. private _setupSkyboxMaterial;
  9957. /**
  9958. * Setup the skybox reflection texture according to the specified options.
  9959. */
  9960. private _setupSkyboxReflectionTexture;
  9961. private _errorHandler;
  9962. /**
  9963. * Dispose all the elements created by the Helper.
  9964. */
  9965. dispose(): void;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  9971. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  9972. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  9973. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9974. */
  9975. class PhotoDome extends Node {
  9976. private _useDirectMapping;
  9977. /**
  9978. * The texture being displayed on the sphere
  9979. */
  9980. protected _photoTexture: Texture;
  9981. /**
  9982. * Gets or sets the texture being displayed on the sphere
  9983. */
  9984. photoTexture: Texture;
  9985. /**
  9986. * The skybox material
  9987. */
  9988. protected _material: BackgroundMaterial;
  9989. /**
  9990. * The surface used for the skybox
  9991. */
  9992. protected _mesh: Mesh;
  9993. /**
  9994. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9995. * Also see the options.resolution property.
  9996. */
  9997. fovMultiplier: number;
  9998. /**
  9999. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10000. * @param name Element's name, child elements will append suffixes for their own names.
  10001. * @param urlsOfPhoto define the url of the photo to display
  10002. * @param options An object containing optional or exposed sub element properties
  10003. */
  10004. constructor(name: string, urlOfPhoto: string, options: {
  10005. resolution?: number;
  10006. size?: number;
  10007. useDirectMapping?: boolean;
  10008. }, scene: Scene);
  10009. /**
  10010. * Releases resources associated with this node.
  10011. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10012. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10013. */
  10014. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10015. }
  10016. }
  10017. declare module BABYLON {
  10018. /**
  10019. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10020. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10021. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10022. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10023. */
  10024. class VideoDome extends Node {
  10025. private _useDirectMapping;
  10026. /**
  10027. * The video texture being displayed on the sphere
  10028. */
  10029. protected _videoTexture: VideoTexture;
  10030. /**
  10031. * Gets the video texture being displayed on the sphere
  10032. */
  10033. readonly videoTexture: VideoTexture;
  10034. /**
  10035. * The skybox material
  10036. */
  10037. protected _material: BackgroundMaterial;
  10038. /**
  10039. * The surface used for the skybox
  10040. */
  10041. protected _mesh: Mesh;
  10042. /**
  10043. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10044. * Also see the options.resolution property.
  10045. */
  10046. fovMultiplier: number;
  10047. /**
  10048. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10049. * @param name Element's name, child elements will append suffixes for their own names.
  10050. * @param urlsOrVideo defines the url(s) or the video element to use
  10051. * @param options An object containing optional or exposed sub element properties
  10052. */
  10053. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10054. resolution?: number;
  10055. clickToPlay?: boolean;
  10056. autoPlay?: boolean;
  10057. loop?: boolean;
  10058. size?: number;
  10059. poster?: string;
  10060. useDirectMapping?: boolean;
  10061. }, scene: Scene);
  10062. /**
  10063. * Releases resources associated with this node.
  10064. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10065. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10066. */
  10067. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10068. }
  10069. }
  10070. declare module BABYLON {
  10071. /**
  10072. * Single axis drag gizmo
  10073. */
  10074. class AxisDragGizmo extends Gizmo {
  10075. /**
  10076. * Drag behavior responsible for the gizmos dragging interactions
  10077. */
  10078. dragBehavior: PointerDragBehavior;
  10079. private _pointerObserver;
  10080. /**
  10081. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10082. */
  10083. snapDistance: number;
  10084. /**
  10085. * Event that fires each time the gizmo snaps to a new location.
  10086. * * snapDistance is the the change in distance
  10087. */
  10088. onSnapObservable: Observable<{
  10089. snapDistance: number;
  10090. }>;
  10091. /**
  10092. * Creates an AxisDragGizmo
  10093. * @param gizmoLayer The utility layer the gizmo will be added to
  10094. * @param dragAxis The axis which the gizmo will be able to drag on
  10095. * @param color The color of the gizmo
  10096. */
  10097. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10098. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10099. /**
  10100. * Disposes of the gizmo
  10101. */
  10102. dispose(): void;
  10103. }
  10104. }
  10105. declare module BABYLON {
  10106. /**
  10107. * Single axis scale gizmo
  10108. */
  10109. class AxisScaleGizmo extends Gizmo {
  10110. private _coloredMaterial;
  10111. /**
  10112. * Drag behavior responsible for the gizmos dragging interactions
  10113. */
  10114. dragBehavior: PointerDragBehavior;
  10115. private _pointerObserver;
  10116. /**
  10117. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10118. */
  10119. snapDistance: number;
  10120. /**
  10121. * Event that fires each time the gizmo snaps to a new location.
  10122. * * snapDistance is the the change in distance
  10123. */
  10124. onSnapObservable: Observable<{
  10125. snapDistance: number;
  10126. }>;
  10127. /**
  10128. * If the scaling operation should be done on all axis (default: false)
  10129. */
  10130. uniformScaling: boolean;
  10131. /**
  10132. * Creates an AxisScaleGizmo
  10133. * @param gizmoLayer The utility layer the gizmo will be added to
  10134. * @param dragAxis The axis which the gizmo will be able to scale on
  10135. * @param color The color of the gizmo
  10136. */
  10137. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10138. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10139. /**
  10140. * Disposes of the gizmo
  10141. */
  10142. dispose(): void;
  10143. /**
  10144. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10145. * @param mesh The mesh to replace the default mesh of the gizmo
  10146. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  10147. */
  10148. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  10149. }
  10150. }
  10151. declare module BABYLON {
  10152. /**
  10153. * Bounding box gizmo
  10154. */
  10155. class BoundingBoxGizmo extends Gizmo {
  10156. private _lineBoundingBox;
  10157. private _rotateSpheresParent;
  10158. private _scaleBoxesParent;
  10159. private _boundingDimensions;
  10160. private _renderObserver;
  10161. private _pointerObserver;
  10162. private _scaleDragSpeed;
  10163. private _tmpQuaternion;
  10164. private _tmpVector;
  10165. /**
  10166. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  10167. */
  10168. ignoreChildren: boolean;
  10169. /**
  10170. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  10171. */
  10172. rotationSphereSize: number;
  10173. /**
  10174. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  10175. */
  10176. scaleBoxSize: number;
  10177. /**
  10178. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  10179. */
  10180. fixedDragMeshScreenSize: boolean;
  10181. /**
  10182. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  10183. */
  10184. fixedDragMeshScreenSizeDistanceFactor: number;
  10185. /**
  10186. * Fired when a rotation sphere or scale box is dragged
  10187. */
  10188. onDragStartObservable: Observable<{}>;
  10189. /**
  10190. * Fired when a scale box is dragged
  10191. */
  10192. onScaleBoxDragObservable: Observable<{}>;
  10193. /**
  10194. * Fired when a scale box drag is ended
  10195. */
  10196. onScaleBoxDragEndObservable: Observable<{}>;
  10197. /**
  10198. * Fired when a rotation sphere is dragged
  10199. */
  10200. onRotationSphereDragObservable: Observable<{}>;
  10201. /**
  10202. * Fired when a rotation sphere drag is ended
  10203. */
  10204. onRotationSphereDragEndObservable: Observable<{}>;
  10205. private _anchorMesh;
  10206. private _existingMeshScale;
  10207. /**
  10208. * Creates an BoundingBoxGizmo
  10209. * @param gizmoLayer The utility layer the gizmo will be added to
  10210. * @param color The color of the gizmo
  10211. */
  10212. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10213. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10214. private _selectNode;
  10215. private _recurseComputeWorld;
  10216. /**
  10217. * Updates the bounding box information for the Gizmo
  10218. */
  10219. updateBoundingBox(): void;
  10220. /**
  10221. * Enables rotation on the specified axis and disables rotation on the others
  10222. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  10223. */
  10224. setEnabledRotationAxis(axis: string): void;
  10225. /**
  10226. * Disposes of the gizmo
  10227. */
  10228. dispose(): void;
  10229. /**
  10230. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  10231. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  10232. * @returns the bounding box mesh with the passed in mesh as a child
  10233. */
  10234. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  10235. /**
  10236. * CustomMeshes are not supported by this gizmo
  10237. * @param mesh The mesh to replace the default mesh of the gizmo
  10238. */
  10239. setCustomMesh(mesh: Mesh): void;
  10240. }
  10241. }
  10242. declare module BABYLON {
  10243. /**
  10244. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10245. */
  10246. class Gizmo implements IDisposable {
  10247. /** The utility layer the gizmo will be added to */
  10248. gizmoLayer: UtilityLayerRenderer;
  10249. /**
  10250. * The root mesh of the gizmo
  10251. */
  10252. protected _rootMesh: Mesh;
  10253. private _attachedMesh;
  10254. private _scaleFactor;
  10255. private _tmpMatrix;
  10256. /**
  10257. * If a custom mesh has been set (Default: false)
  10258. */
  10259. protected _customMeshSet: boolean;
  10260. /**
  10261. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10262. * * When set, interactions will be enabled
  10263. */
  10264. attachedMesh: Nullable<AbstractMesh>;
  10265. /**
  10266. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10267. * @param mesh The mesh to replace the default mesh of the gizmo
  10268. */
  10269. setCustomMesh(mesh: Mesh): void;
  10270. /**
  10271. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10272. */
  10273. updateGizmoRotationToMatchAttachedMesh: boolean;
  10274. /**
  10275. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10276. */
  10277. updateGizmoPositionToMatchAttachedMesh: boolean;
  10278. /**
  10279. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10280. */
  10281. protected _updateScale: boolean;
  10282. protected _interactionsEnabled: boolean;
  10283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10284. private _beforeRenderObserver;
  10285. /**
  10286. * Creates a gizmo
  10287. * @param gizmoLayer The utility layer the gizmo will be added to
  10288. */
  10289. constructor(
  10290. /** The utility layer the gizmo will be added to */
  10291. gizmoLayer?: UtilityLayerRenderer);
  10292. private _tempVector;
  10293. /**
  10294. * @hidden
  10295. * Updates the gizmo to match the attached mesh's position/rotation
  10296. */
  10297. protected _update(): void;
  10298. /**
  10299. * Disposes of the gizmo
  10300. */
  10301. dispose(): void;
  10302. }
  10303. }
  10304. declare module BABYLON {
  10305. /**
  10306. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10307. */
  10308. class GizmoManager implements IDisposable {
  10309. private scene;
  10310. /**
  10311. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10312. */
  10313. gizmos: {
  10314. positionGizmo: Nullable<PositionGizmo>;
  10315. rotationGizmo: Nullable<RotationGizmo>;
  10316. scaleGizmo: Nullable<ScaleGizmo>;
  10317. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10318. };
  10319. private _gizmosEnabled;
  10320. private _gizmoLayer;
  10321. private _pointerObserver;
  10322. private _attachedMesh;
  10323. private _boundingBoxColor;
  10324. private _dragBehavior;
  10325. /**
  10326. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10327. */
  10328. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10329. /**
  10330. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10331. */
  10332. usePointerToAttachGizmos: boolean;
  10333. /**
  10334. * Instatiates a gizmo manager
  10335. * @param scene the scene to overlay the gizmos on top of
  10336. */
  10337. constructor(scene: Scene);
  10338. /**
  10339. * Attaches a set of gizmos to the specified mesh
  10340. * @param mesh The mesh the gizmo's should be attached to
  10341. */
  10342. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10343. /**
  10344. * If the position gizmo is enabled
  10345. */
  10346. positionGizmoEnabled: boolean;
  10347. /**
  10348. * If the rotation gizmo is enabled
  10349. */
  10350. rotationGizmoEnabled: boolean;
  10351. /**
  10352. * If the scale gizmo is enabled
  10353. */
  10354. scaleGizmoEnabled: boolean;
  10355. /**
  10356. * If the boundingBox gizmo is enabled
  10357. */
  10358. boundingBoxGizmoEnabled: boolean;
  10359. /**
  10360. * Disposes of the gizmo manager
  10361. */
  10362. dispose(): void;
  10363. }
  10364. }
  10365. declare module BABYLON {
  10366. /**
  10367. * Single plane rotation gizmo
  10368. */
  10369. class PlaneRotationGizmo extends Gizmo {
  10370. /**
  10371. * Drag behavior responsible for the gizmos dragging interactions
  10372. */
  10373. dragBehavior: PointerDragBehavior;
  10374. private _pointerObserver;
  10375. /**
  10376. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10377. */
  10378. snapDistance: number;
  10379. /**
  10380. * Event that fires each time the gizmo snaps to a new location.
  10381. * * snapDistance is the the change in distance
  10382. */
  10383. onSnapObservable: Observable<{
  10384. snapDistance: number;
  10385. }>;
  10386. /**
  10387. * Creates a PlaneRotationGizmo
  10388. * @param gizmoLayer The utility layer the gizmo will be added to
  10389. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10390. * @param color The color of the gizmo
  10391. */
  10392. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10393. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10394. /**
  10395. * Disposes of the gizmo
  10396. */
  10397. dispose(): void;
  10398. }
  10399. }
  10400. declare module BABYLON {
  10401. /**
  10402. * Gizmo that enables dragging a mesh along 3 axis
  10403. */
  10404. class PositionGizmo extends Gizmo {
  10405. /**
  10406. * Internal gizmo used for interactions on the x axis
  10407. */
  10408. xGizmo: AxisDragGizmo;
  10409. /**
  10410. * Internal gizmo used for interactions on the y axis
  10411. */
  10412. yGizmo: AxisDragGizmo;
  10413. /**
  10414. * Internal gizmo used for interactions on the z axis
  10415. */
  10416. zGizmo: AxisDragGizmo;
  10417. attachedMesh: Nullable<AbstractMesh>;
  10418. /**
  10419. * Creates a PositionGizmo
  10420. * @param gizmoLayer The utility layer the gizmo will be added to
  10421. */
  10422. constructor(gizmoLayer?: UtilityLayerRenderer);
  10423. updateGizmoRotationToMatchAttachedMesh: boolean;
  10424. /**
  10425. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10426. */
  10427. snapDistance: number;
  10428. /**
  10429. * Disposes of the gizmo
  10430. */
  10431. dispose(): void;
  10432. /**
  10433. * CustomMeshes are not supported by this gizmo
  10434. * @param mesh The mesh to replace the default mesh of the gizmo
  10435. */
  10436. setCustomMesh(mesh: Mesh): void;
  10437. }
  10438. }
  10439. declare module BABYLON {
  10440. /**
  10441. * Gizmo that enables rotating a mesh along 3 axis
  10442. */
  10443. class RotationGizmo extends Gizmo {
  10444. /**
  10445. * Internal gizmo used for interactions on the x axis
  10446. */
  10447. xGizmo: PlaneRotationGizmo;
  10448. /**
  10449. * Internal gizmo used for interactions on the y axis
  10450. */
  10451. yGizmo: PlaneRotationGizmo;
  10452. /**
  10453. * Internal gizmo used for interactions on the z axis
  10454. */
  10455. zGizmo: PlaneRotationGizmo;
  10456. attachedMesh: Nullable<AbstractMesh>;
  10457. /**
  10458. * Creates a RotationGizmo
  10459. * @param gizmoLayer The utility layer the gizmo will be added to
  10460. */
  10461. constructor(gizmoLayer?: UtilityLayerRenderer);
  10462. updateGizmoRotationToMatchAttachedMesh: boolean;
  10463. /**
  10464. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10465. */
  10466. snapDistance: number;
  10467. /**
  10468. * Disposes of the gizmo
  10469. */
  10470. dispose(): void;
  10471. /**
  10472. * CustomMeshes are not supported by this gizmo
  10473. * @param mesh The mesh to replace the default mesh of the gizmo
  10474. */
  10475. setCustomMesh(mesh: Mesh): void;
  10476. }
  10477. }
  10478. declare module BABYLON {
  10479. /**
  10480. * Gizmo that enables scaling a mesh along 3 axis
  10481. */
  10482. class ScaleGizmo extends Gizmo {
  10483. /**
  10484. * Internal gizmo used for interactions on the x axis
  10485. */
  10486. xGizmo: AxisScaleGizmo;
  10487. /**
  10488. * Internal gizmo used for interactions on the y axis
  10489. */
  10490. yGizmo: AxisScaleGizmo;
  10491. /**
  10492. * Internal gizmo used for interactions on the z axis
  10493. */
  10494. zGizmo: AxisScaleGizmo;
  10495. /**
  10496. * @hidden
  10497. * Internal gizmo used to scale all axis equally
  10498. */
  10499. private _uniformGizmo;
  10500. attachedMesh: Nullable<AbstractMesh>;
  10501. /**
  10502. * Creates a ScaleGizmo
  10503. * @param gizmoLayer The utility layer the gizmo will be added to
  10504. */
  10505. constructor(gizmoLayer?: UtilityLayerRenderer);
  10506. updateGizmoRotationToMatchAttachedMesh: boolean;
  10507. /**
  10508. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10509. */
  10510. snapDistance: number;
  10511. /**
  10512. * Disposes of the gizmo
  10513. */
  10514. dispose(): void;
  10515. }
  10516. }
  10517. declare module BABYLON {
  10518. /**
  10519. * This class can be used to get instrumentation data from a Babylon engine
  10520. */
  10521. class EngineInstrumentation implements IDisposable {
  10522. engine: Engine;
  10523. private _captureGPUFrameTime;
  10524. private _gpuFrameTimeToken;
  10525. private _gpuFrameTime;
  10526. private _captureShaderCompilationTime;
  10527. private _shaderCompilationTime;
  10528. private _onBeginFrameObserver;
  10529. private _onEndFrameObserver;
  10530. private _onBeforeShaderCompilationObserver;
  10531. private _onAfterShaderCompilationObserver;
  10532. /**
  10533. * Gets the perf counter used for GPU frame time
  10534. */
  10535. readonly gpuFrameTimeCounter: PerfCounter;
  10536. /**
  10537. * Gets the GPU frame time capture status
  10538. */
  10539. /**
  10540. * Enable or disable the GPU frame time capture
  10541. */
  10542. captureGPUFrameTime: boolean;
  10543. /**
  10544. * Gets the perf counter used for shader compilation time
  10545. */
  10546. readonly shaderCompilationTimeCounter: PerfCounter;
  10547. /**
  10548. * Gets the shader compilation time capture status
  10549. */
  10550. /**
  10551. * Enable or disable the shader compilation time capture
  10552. */
  10553. captureShaderCompilationTime: boolean;
  10554. constructor(engine: Engine);
  10555. dispose(): void;
  10556. }
  10557. }
  10558. declare module BABYLON {
  10559. /**
  10560. * This class can be used to get instrumentation data from a Babylon engine
  10561. */
  10562. class SceneInstrumentation implements IDisposable {
  10563. scene: Scene;
  10564. private _captureActiveMeshesEvaluationTime;
  10565. private _activeMeshesEvaluationTime;
  10566. private _captureRenderTargetsRenderTime;
  10567. private _renderTargetsRenderTime;
  10568. private _captureFrameTime;
  10569. private _frameTime;
  10570. private _captureRenderTime;
  10571. private _renderTime;
  10572. private _captureInterFrameTime;
  10573. private _interFrameTime;
  10574. private _captureParticlesRenderTime;
  10575. private _particlesRenderTime;
  10576. private _captureSpritesRenderTime;
  10577. private _spritesRenderTime;
  10578. private _capturePhysicsTime;
  10579. private _physicsTime;
  10580. private _captureAnimationsTime;
  10581. private _animationsTime;
  10582. private _captureCameraRenderTime;
  10583. private _cameraRenderTime;
  10584. private _onBeforeActiveMeshesEvaluationObserver;
  10585. private _onAfterActiveMeshesEvaluationObserver;
  10586. private _onBeforeRenderTargetsRenderObserver;
  10587. private _onAfterRenderTargetsRenderObserver;
  10588. private _onAfterRenderObserver;
  10589. private _onBeforeDrawPhaseObserver;
  10590. private _onAfterDrawPhaseObserver;
  10591. private _onBeforeAnimationsObserver;
  10592. private _onBeforeParticlesRenderingObserver;
  10593. private _onAfterParticlesRenderingObserver;
  10594. private _onBeforeSpritesRenderingObserver;
  10595. private _onAfterSpritesRenderingObserver;
  10596. private _onBeforePhysicsObserver;
  10597. private _onAfterPhysicsObserver;
  10598. private _onAfterAnimationsObserver;
  10599. private _onBeforeCameraRenderObserver;
  10600. private _onAfterCameraRenderObserver;
  10601. /**
  10602. * Gets the perf counter used for active meshes evaluation time
  10603. */
  10604. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10605. /**
  10606. * Gets the active meshes evaluation time capture status
  10607. */
  10608. /**
  10609. * Enable or disable the active meshes evaluation time capture
  10610. */
  10611. captureActiveMeshesEvaluationTime: boolean;
  10612. /**
  10613. * Gets the perf counter used for render targets render time
  10614. */
  10615. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10616. /**
  10617. * Gets the render targets render time capture status
  10618. */
  10619. /**
  10620. * Enable or disable the render targets render time capture
  10621. */
  10622. captureRenderTargetsRenderTime: boolean;
  10623. /**
  10624. * Gets the perf counter used for particles render time
  10625. */
  10626. readonly particlesRenderTimeCounter: PerfCounter;
  10627. /**
  10628. * Gets the particles render time capture status
  10629. */
  10630. /**
  10631. * Enable or disable the particles render time capture
  10632. */
  10633. captureParticlesRenderTime: boolean;
  10634. /**
  10635. * Gets the perf counter used for sprites render time
  10636. */
  10637. readonly spritesRenderTimeCounter: PerfCounter;
  10638. /**
  10639. * Gets the sprites render time capture status
  10640. */
  10641. /**
  10642. * Enable or disable the sprites render time capture
  10643. */
  10644. captureSpritesRenderTime: boolean;
  10645. /**
  10646. * Gets the perf counter used for physics time
  10647. */
  10648. readonly physicsTimeCounter: PerfCounter;
  10649. /**
  10650. * Gets the physics time capture status
  10651. */
  10652. /**
  10653. * Enable or disable the physics time capture
  10654. */
  10655. capturePhysicsTime: boolean;
  10656. /**
  10657. * Gets the perf counter used for animations time
  10658. */
  10659. readonly animationsTimeCounter: PerfCounter;
  10660. /**
  10661. * Gets the animations time capture status
  10662. */
  10663. /**
  10664. * Enable or disable the animations time capture
  10665. */
  10666. captureAnimationsTime: boolean;
  10667. /**
  10668. * Gets the perf counter used for frame time capture
  10669. */
  10670. readonly frameTimeCounter: PerfCounter;
  10671. /**
  10672. * Gets the frame time capture status
  10673. */
  10674. /**
  10675. * Enable or disable the frame time capture
  10676. */
  10677. captureFrameTime: boolean;
  10678. /**
  10679. * Gets the perf counter used for inter-frames time capture
  10680. */
  10681. readonly interFrameTimeCounter: PerfCounter;
  10682. /**
  10683. * Gets the inter-frames time capture status
  10684. */
  10685. /**
  10686. * Enable or disable the inter-frames time capture
  10687. */
  10688. captureInterFrameTime: boolean;
  10689. /**
  10690. * Gets the perf counter used for render time capture
  10691. */
  10692. readonly renderTimeCounter: PerfCounter;
  10693. /**
  10694. * Gets the render time capture status
  10695. */
  10696. /**
  10697. * Enable or disable the render time capture
  10698. */
  10699. captureRenderTime: boolean;
  10700. /**
  10701. * Gets the perf counter used for camera render time capture
  10702. */
  10703. readonly cameraRenderTimeCounter: PerfCounter;
  10704. /**
  10705. * Gets the camera render time capture status
  10706. */
  10707. /**
  10708. * Enable or disable the camera render time capture
  10709. */
  10710. captureCameraRenderTime: boolean;
  10711. /**
  10712. * Gets the perf counter used for draw calls
  10713. */
  10714. readonly drawCallsCounter: PerfCounter;
  10715. /**
  10716. * Gets the perf counter used for texture collisions
  10717. */
  10718. readonly textureCollisionsCounter: PerfCounter;
  10719. constructor(scene: Scene);
  10720. dispose(): void;
  10721. }
  10722. }
  10723. declare module BABYLON {
  10724. /**
  10725. * @hidden
  10726. **/
  10727. class _TimeToken {
  10728. _startTimeQuery: Nullable<WebGLQuery>;
  10729. _endTimeQuery: Nullable<WebGLQuery>;
  10730. _timeElapsedQuery: Nullable<WebGLQuery>;
  10731. _timeElapsedQueryEnded: boolean;
  10732. }
  10733. }
  10734. declare module BABYLON {
  10735. /**
  10736. * Effect layer options. This helps customizing the behaviour
  10737. * of the effect layer.
  10738. */
  10739. interface IEffectLayerOptions {
  10740. /**
  10741. * Multiplication factor apply to the canvas size to compute the render target size
  10742. * used to generated the objects (the smaller the faster).
  10743. */
  10744. mainTextureRatio: number;
  10745. /**
  10746. * Enforces a fixed size texture to ensure effect stability across devices.
  10747. */
  10748. mainTextureFixedSize?: number;
  10749. /**
  10750. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10751. */
  10752. alphaBlendingMode: number;
  10753. /**
  10754. * The camera attached to the layer.
  10755. */
  10756. camera: Nullable<Camera>;
  10757. /**
  10758. * The rendering group to draw the layer in.
  10759. */
  10760. renderingGroupId: number;
  10761. }
  10762. /**
  10763. * The effect layer Helps adding post process effect blended with the main pass.
  10764. *
  10765. * This can be for instance use to generate glow or higlight effects on the scene.
  10766. *
  10767. * The effect layer class can not be used directly and is intented to inherited from to be
  10768. * customized per effects.
  10769. */
  10770. abstract class EffectLayer {
  10771. private _vertexBuffers;
  10772. private _indexBuffer;
  10773. private _cachedDefines;
  10774. private _effectLayerMapGenerationEffect;
  10775. private _effectLayerOptions;
  10776. private _mergeEffect;
  10777. protected _scene: Scene;
  10778. protected _engine: Engine;
  10779. protected _maxSize: number;
  10780. protected _mainTextureDesiredSize: ISize;
  10781. protected _mainTexture: RenderTargetTexture;
  10782. protected _shouldRender: boolean;
  10783. protected _postProcesses: PostProcess[];
  10784. protected _textures: BaseTexture[];
  10785. protected _emissiveTextureAndColor: {
  10786. texture: Nullable<BaseTexture>;
  10787. color: Color4;
  10788. };
  10789. /**
  10790. * The name of the layer
  10791. */
  10792. name: string;
  10793. /**
  10794. * The clear color of the texture used to generate the glow map.
  10795. */
  10796. neutralColor: Color4;
  10797. /**
  10798. * Specifies wether the highlight layer is enabled or not.
  10799. */
  10800. isEnabled: boolean;
  10801. /**
  10802. * Gets the camera attached to the layer.
  10803. */
  10804. readonly camera: Nullable<Camera>;
  10805. /**
  10806. * Gets the rendering group id the layer should render in.
  10807. */
  10808. readonly renderingGroupId: number;
  10809. /**
  10810. * An event triggered when the effect layer has been disposed.
  10811. */
  10812. onDisposeObservable: Observable<EffectLayer>;
  10813. /**
  10814. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10815. */
  10816. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10817. /**
  10818. * An event triggered when the generated texture is being merged in the scene.
  10819. */
  10820. onBeforeComposeObservable: Observable<EffectLayer>;
  10821. /**
  10822. * An event triggered when the generated texture has been merged in the scene.
  10823. */
  10824. onAfterComposeObservable: Observable<EffectLayer>;
  10825. /**
  10826. * An event triggered when the efffect layer changes its size.
  10827. */
  10828. onSizeChangedObservable: Observable<EffectLayer>;
  10829. /**
  10830. * Instantiates a new effect Layer and references it in the scene.
  10831. * @param name The name of the layer
  10832. * @param scene The scene to use the layer in
  10833. */
  10834. constructor(
  10835. /** The Friendly of the effect in the scene */
  10836. name: string, scene: Scene);
  10837. /**
  10838. * Get the effect name of the layer.
  10839. * @return The effect name
  10840. */
  10841. abstract getEffectName(): string;
  10842. /**
  10843. * Checks for the readiness of the element composing the layer.
  10844. * @param subMesh the mesh to check for
  10845. * @param useInstances specify wether or not to use instances to render the mesh
  10846. * @return true if ready otherwise, false
  10847. */
  10848. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10849. /**
  10850. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10851. * @returns true if the effect requires stencil during the main canvas render pass.
  10852. */
  10853. abstract needStencil(): boolean;
  10854. /**
  10855. * Create the merge effect. This is the shader use to blit the information back
  10856. * to the main canvas at the end of the scene rendering.
  10857. * @returns The effect containing the shader used to merge the effect on the main canvas
  10858. */
  10859. protected abstract _createMergeEffect(): Effect;
  10860. /**
  10861. * Creates the render target textures and post processes used in the effect layer.
  10862. */
  10863. protected abstract _createTextureAndPostProcesses(): void;
  10864. /**
  10865. * Implementation specific of rendering the generating effect on the main canvas.
  10866. * @param effect The effect used to render through
  10867. */
  10868. protected abstract _internalRender(effect: Effect): void;
  10869. /**
  10870. * Sets the required values for both the emissive texture and and the main color.
  10871. */
  10872. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10873. /**
  10874. * Free any resources and references associated to a mesh.
  10875. * Internal use
  10876. * @param mesh The mesh to free.
  10877. */
  10878. abstract _disposeMesh(mesh: Mesh): void;
  10879. /**
  10880. * Serializes this layer (Glow or Highlight for example)
  10881. * @returns a serialized layer object
  10882. */
  10883. abstract serialize?(): any;
  10884. /**
  10885. * Initializes the effect layer with the required options.
  10886. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10887. */
  10888. protected _init(options: Partial<IEffectLayerOptions>): void;
  10889. /**
  10890. * Generates the index buffer of the full screen quad blending to the main canvas.
  10891. */
  10892. private _generateIndexBuffer;
  10893. /**
  10894. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10895. */
  10896. private _genrateVertexBuffer;
  10897. /**
  10898. * Sets the main texture desired size which is the closest power of two
  10899. * of the engine canvas size.
  10900. */
  10901. private _setMainTextureSize;
  10902. /**
  10903. * Creates the main texture for the effect layer.
  10904. */
  10905. protected _createMainTexture(): void;
  10906. /**
  10907. * Checks for the readiness of the element composing the layer.
  10908. * @param subMesh the mesh to check for
  10909. * @param useInstances specify wether or not to use instances to render the mesh
  10910. * @param emissiveTexture the associated emissive texture used to generate the glow
  10911. * @return true if ready otherwise, false
  10912. */
  10913. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10914. /**
  10915. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10916. */
  10917. render(): void;
  10918. /**
  10919. * Determine if a given mesh will be used in the current effect.
  10920. * @param mesh mesh to test
  10921. * @returns true if the mesh will be used
  10922. */
  10923. hasMesh(mesh: AbstractMesh): boolean;
  10924. /**
  10925. * Returns true if the layer contains information to display, otherwise false.
  10926. * @returns true if the glow layer should be rendered
  10927. */
  10928. shouldRender(): boolean;
  10929. /**
  10930. * Returns true if the mesh should render, otherwise false.
  10931. * @param mesh The mesh to render
  10932. * @returns true if it should render otherwise false
  10933. */
  10934. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10935. /**
  10936. * Returns true if the mesh should render, otherwise false.
  10937. * @param mesh The mesh to render
  10938. * @returns true if it should render otherwise false
  10939. */
  10940. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10941. /**
  10942. * Renders the submesh passed in parameter to the generation map.
  10943. */
  10944. protected _renderSubMesh(subMesh: SubMesh): void;
  10945. /**
  10946. * Rebuild the required buffers.
  10947. * @hidden Internal use only.
  10948. */
  10949. _rebuild(): void;
  10950. /**
  10951. * Dispose only the render target textures and post process.
  10952. */
  10953. private _disposeTextureAndPostProcesses;
  10954. /**
  10955. * Dispose the highlight layer and free resources.
  10956. */
  10957. dispose(): void;
  10958. /**
  10959. * Gets the class name of the effect layer
  10960. * @returns the string with the class name of the effect layer
  10961. */
  10962. getClassName(): string;
  10963. /**
  10964. * Creates an effect layer from parsed effect layer data
  10965. * @param parsedEffectLayer defines effect layer data
  10966. * @param scene defines the current scene
  10967. * @param rootUrl defines the root URL containing the effect layer information
  10968. * @returns a parsed effect Layer
  10969. */
  10970. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10971. }
  10972. }
  10973. declare module BABYLON {
  10974. interface AbstractScene {
  10975. /**
  10976. * The list of effect layers (highlights/glow) added to the scene
  10977. * @see http://doc.babylonjs.com/how_to/highlight_layer
  10978. * @see http://doc.babylonjs.com/how_to/glow_layer
  10979. */
  10980. effectLayers: Array<EffectLayer>;
  10981. /**
  10982. * Removes the given effect layer from this scene.
  10983. * @param toRemove defines the effect layer to remove
  10984. * @returns the index of the removed effect layer
  10985. */
  10986. removeEffectLayer(toRemove: EffectLayer): number;
  10987. /**
  10988. * Adds the given effect layer to this scene
  10989. * @param newEffectLayer defines the effect layer to add
  10990. */
  10991. addEffectLayer(newEffectLayer: EffectLayer): void;
  10992. }
  10993. /**
  10994. * Defines the layer scene component responsible to manage any effect layers
  10995. * in a given scene.
  10996. */
  10997. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  10998. /**
  10999. * The component name helpfull to identify the component in the list of scene components.
  11000. */
  11001. readonly name: string;
  11002. /**
  11003. * The scene the component belongs to.
  11004. */
  11005. scene: Scene;
  11006. private _engine;
  11007. private _renderEffects;
  11008. private _needStencil;
  11009. private _previousStencilState;
  11010. /**
  11011. * Creates a new instance of the component for the given scene
  11012. * @param scene Defines the scene to register the component in
  11013. */
  11014. constructor(scene: Scene);
  11015. /**
  11016. * Registers the component in a given scene
  11017. */
  11018. register(): void;
  11019. /**
  11020. * Rebuilds the elements related to this component in case of
  11021. * context lost for instance.
  11022. */
  11023. rebuild(): void;
  11024. /**
  11025. * Serializes the component data to the specified json object
  11026. * @param serializationObject The object to serialize to
  11027. */
  11028. serialize(serializationObject: any): void;
  11029. /**
  11030. * Adds all the element from the container to the scene
  11031. * @param container the container holding the elements
  11032. */
  11033. addFromContainer(container: AbstractScene): void;
  11034. /**
  11035. * Removes all the elements in the container from the scene
  11036. * @param container contains the elements to remove
  11037. */
  11038. removeFromContainer(container: AbstractScene): void;
  11039. /**
  11040. * Disposes the component and the associated ressources.
  11041. */
  11042. dispose(): void;
  11043. private _isReadyForMesh;
  11044. private _renderMainTexture;
  11045. private _setStencil;
  11046. private _setStencilBack;
  11047. private _draw;
  11048. private _drawCamera;
  11049. private _drawRenderingGroup;
  11050. }
  11051. }
  11052. declare module BABYLON {
  11053. interface AbstractScene {
  11054. /**
  11055. * Return a the first highlight layer of the scene with a given name.
  11056. * @param name The name of the highlight layer to look for.
  11057. * @return The highlight layer if found otherwise null.
  11058. */
  11059. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11060. }
  11061. /**
  11062. * Glow layer options. This helps customizing the behaviour
  11063. * of the glow layer.
  11064. */
  11065. interface IGlowLayerOptions {
  11066. /**
  11067. * Multiplication factor apply to the canvas size to compute the render target size
  11068. * used to generated the glowing objects (the smaller the faster).
  11069. */
  11070. mainTextureRatio: number;
  11071. /**
  11072. * Enforces a fixed size texture to ensure resize independant blur.
  11073. */
  11074. mainTextureFixedSize?: number;
  11075. /**
  11076. * How big is the kernel of the blur texture.
  11077. */
  11078. blurKernelSize: number;
  11079. /**
  11080. * The camera attached to the layer.
  11081. */
  11082. camera: Nullable<Camera>;
  11083. /**
  11084. * Enable MSAA by chosing the number of samples.
  11085. */
  11086. mainTextureSamples?: number;
  11087. /**
  11088. * The rendering group to draw the layer in.
  11089. */
  11090. renderingGroupId: number;
  11091. }
  11092. /**
  11093. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11094. *
  11095. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11096. * glowy meshes to your scene.
  11097. *
  11098. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11099. */
  11100. class GlowLayer extends EffectLayer {
  11101. /**
  11102. * Effect Name of the layer.
  11103. */
  11104. static readonly EffectName: string;
  11105. /**
  11106. * The default blur kernel size used for the glow.
  11107. */
  11108. static DefaultBlurKernelSize: number;
  11109. /**
  11110. * The default texture size ratio used for the glow.
  11111. */
  11112. static DefaultTextureRatio: number;
  11113. /**
  11114. * Sets the kernel size of the blur.
  11115. */
  11116. /**
  11117. * Gets the kernel size of the blur.
  11118. */
  11119. blurKernelSize: number;
  11120. /**
  11121. * Sets the glow intensity.
  11122. */
  11123. /**
  11124. * Gets the glow intensity.
  11125. */
  11126. intensity: number;
  11127. private _options;
  11128. private _intensity;
  11129. private _horizontalBlurPostprocess1;
  11130. private _verticalBlurPostprocess1;
  11131. private _horizontalBlurPostprocess2;
  11132. private _verticalBlurPostprocess2;
  11133. private _blurTexture1;
  11134. private _blurTexture2;
  11135. private _postProcesses1;
  11136. private _postProcesses2;
  11137. private _includedOnlyMeshes;
  11138. private _excludedMeshes;
  11139. /**
  11140. * Callback used to let the user override the color selection on a per mesh basis
  11141. */
  11142. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11143. /**
  11144. * Callback used to let the user override the texture selection on a per mesh basis
  11145. */
  11146. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11147. /**
  11148. * Instantiates a new glow Layer and references it to the scene.
  11149. * @param name The name of the layer
  11150. * @param scene The scene to use the layer in
  11151. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11152. */
  11153. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11154. /**
  11155. * Get the effect name of the layer.
  11156. * @return The effect name
  11157. */
  11158. getEffectName(): string;
  11159. /**
  11160. * Create the merge effect. This is the shader use to blit the information back
  11161. * to the main canvas at the end of the scene rendering.
  11162. */
  11163. protected _createMergeEffect(): Effect;
  11164. /**
  11165. * Creates the render target textures and post processes used in the glow layer.
  11166. */
  11167. protected _createTextureAndPostProcesses(): void;
  11168. /**
  11169. * Checks for the readiness of the element composing the layer.
  11170. * @param subMesh the mesh to check for
  11171. * @param useInstances specify wether or not to use instances to render the mesh
  11172. * @param emissiveTexture the associated emissive texture used to generate the glow
  11173. * @return true if ready otherwise, false
  11174. */
  11175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11176. /**
  11177. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11178. */
  11179. needStencil(): boolean;
  11180. /**
  11181. * Implementation specific of rendering the generating effect on the main canvas.
  11182. * @param effect The effect used to render through
  11183. */
  11184. protected _internalRender(effect: Effect): void;
  11185. /**
  11186. * Sets the required values for both the emissive texture and and the main color.
  11187. */
  11188. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11189. /**
  11190. * Returns true if the mesh should render, otherwise false.
  11191. * @param mesh The mesh to render
  11192. * @returns true if it should render otherwise false
  11193. */
  11194. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11195. /**
  11196. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11197. * @param mesh The mesh to exclude from the glow layer
  11198. */
  11199. addExcludedMesh(mesh: Mesh): void;
  11200. /**
  11201. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11202. * @param mesh The mesh to remove
  11203. */
  11204. removeExcludedMesh(mesh: Mesh): void;
  11205. /**
  11206. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11207. * @param mesh The mesh to include in the glow layer
  11208. */
  11209. addIncludedOnlyMesh(mesh: Mesh): void;
  11210. /**
  11211. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11212. * @param mesh The mesh to remove
  11213. */
  11214. removeIncludedOnlyMesh(mesh: Mesh): void;
  11215. /**
  11216. * Determine if a given mesh will be used in the glow layer
  11217. * @param mesh The mesh to test
  11218. * @returns true if the mesh will be highlighted by the current glow layer
  11219. */
  11220. hasMesh(mesh: AbstractMesh): boolean;
  11221. /**
  11222. * Free any resources and references associated to a mesh.
  11223. * Internal use
  11224. * @param mesh The mesh to free.
  11225. */
  11226. _disposeMesh(mesh: Mesh): void;
  11227. /**
  11228. * Gets the class name of the effect layer
  11229. * @returns the string with the class name of the effect layer
  11230. */
  11231. getClassName(): string;
  11232. /**
  11233. * Serializes this glow layer
  11234. * @returns a serialized glow layer object
  11235. */
  11236. serialize(): any;
  11237. /**
  11238. * Creates a Glow Layer from parsed glow layer data
  11239. * @param parsedGlowLayer defines glow layer data
  11240. * @param scene defines the current scene
  11241. * @param rootUrl defines the root URL containing the glow layer information
  11242. * @returns a parsed Glow Layer
  11243. */
  11244. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11245. }
  11246. }
  11247. declare module BABYLON {
  11248. interface AbstractScene {
  11249. /**
  11250. * Return a the first highlight layer of the scene with a given name.
  11251. * @param name The name of the highlight layer to look for.
  11252. * @return The highlight layer if found otherwise null.
  11253. */
  11254. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11255. }
  11256. /**
  11257. * Highlight layer options. This helps customizing the behaviour
  11258. * of the highlight layer.
  11259. */
  11260. interface IHighlightLayerOptions {
  11261. /**
  11262. * Multiplication factor apply to the canvas size to compute the render target size
  11263. * used to generated the glowing objects (the smaller the faster).
  11264. */
  11265. mainTextureRatio: number;
  11266. /**
  11267. * Enforces a fixed size texture to ensure resize independant blur.
  11268. */
  11269. mainTextureFixedSize?: number;
  11270. /**
  11271. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11272. * of the picture to blur (the smaller the faster).
  11273. */
  11274. blurTextureSizeRatio: number;
  11275. /**
  11276. * How big in texel of the blur texture is the vertical blur.
  11277. */
  11278. blurVerticalSize: number;
  11279. /**
  11280. * How big in texel of the blur texture is the horizontal blur.
  11281. */
  11282. blurHorizontalSize: number;
  11283. /**
  11284. * Alpha blending mode used to apply the blur. Default is combine.
  11285. */
  11286. alphaBlendingMode: number;
  11287. /**
  11288. * The camera attached to the layer.
  11289. */
  11290. camera: Nullable<Camera>;
  11291. /**
  11292. * Should we display highlight as a solid stroke?
  11293. */
  11294. isStroke?: boolean;
  11295. /**
  11296. * The rendering group to draw the layer in.
  11297. */
  11298. renderingGroupId: number;
  11299. }
  11300. /**
  11301. * The highlight layer Helps adding a glow effect around a mesh.
  11302. *
  11303. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11304. * glowy meshes to your scene.
  11305. *
  11306. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11307. */
  11308. class HighlightLayer extends EffectLayer {
  11309. name: string;
  11310. /**
  11311. * Effect Name of the highlight layer.
  11312. */
  11313. static readonly EffectName: string;
  11314. /**
  11315. * The neutral color used during the preparation of the glow effect.
  11316. * This is black by default as the blend operation is a blend operation.
  11317. */
  11318. static NeutralColor: Color4;
  11319. /**
  11320. * Stencil value used for glowing meshes.
  11321. */
  11322. static GlowingMeshStencilReference: number;
  11323. /**
  11324. * Stencil value used for the other meshes in the scene.
  11325. */
  11326. static NormalMeshStencilReference: number;
  11327. /**
  11328. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11329. */
  11330. innerGlow: boolean;
  11331. /**
  11332. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11333. */
  11334. outerGlow: boolean;
  11335. /**
  11336. * Specifies the horizontal size of the blur.
  11337. */
  11338. /**
  11339. * Gets the horizontal size of the blur.
  11340. */
  11341. blurHorizontalSize: number;
  11342. /**
  11343. * Specifies the vertical size of the blur.
  11344. */
  11345. /**
  11346. * Gets the vertical size of the blur.
  11347. */
  11348. blurVerticalSize: number;
  11349. /**
  11350. * An event triggered when the highlight layer is being blurred.
  11351. */
  11352. onBeforeBlurObservable: Observable<HighlightLayer>;
  11353. /**
  11354. * An event triggered when the highlight layer has been blurred.
  11355. */
  11356. onAfterBlurObservable: Observable<HighlightLayer>;
  11357. private _instanceGlowingMeshStencilReference;
  11358. private _options;
  11359. private _downSamplePostprocess;
  11360. private _horizontalBlurPostprocess;
  11361. private _verticalBlurPostprocess;
  11362. private _blurTexture;
  11363. private _meshes;
  11364. private _excludedMeshes;
  11365. /**
  11366. * Instantiates a new highlight Layer and references it to the scene..
  11367. * @param name The name of the layer
  11368. * @param scene The scene to use the layer in
  11369. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11370. */
  11371. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11372. /**
  11373. * Get the effect name of the layer.
  11374. * @return The effect name
  11375. */
  11376. getEffectName(): string;
  11377. /**
  11378. * Create the merge effect. This is the shader use to blit the information back
  11379. * to the main canvas at the end of the scene rendering.
  11380. */
  11381. protected _createMergeEffect(): Effect;
  11382. /**
  11383. * Creates the render target textures and post processes used in the highlight layer.
  11384. */
  11385. protected _createTextureAndPostProcesses(): void;
  11386. /**
  11387. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11388. */
  11389. needStencil(): boolean;
  11390. /**
  11391. * Checks for the readiness of the element composing the layer.
  11392. * @param subMesh the mesh to check for
  11393. * @param useInstances specify wether or not to use instances to render the mesh
  11394. * @param emissiveTexture the associated emissive texture used to generate the glow
  11395. * @return true if ready otherwise, false
  11396. */
  11397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11398. /**
  11399. * Implementation specific of rendering the generating effect on the main canvas.
  11400. * @param effect The effect used to render through
  11401. */
  11402. protected _internalRender(effect: Effect): void;
  11403. /**
  11404. * Returns true if the layer contains information to display, otherwise false.
  11405. */
  11406. shouldRender(): boolean;
  11407. /**
  11408. * Returns true if the mesh should render, otherwise false.
  11409. * @param mesh The mesh to render
  11410. * @returns true if it should render otherwise false
  11411. */
  11412. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11413. /**
  11414. * Sets the required values for both the emissive texture and and the main color.
  11415. */
  11416. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11417. /**
  11418. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11419. * @param mesh The mesh to exclude from the highlight layer
  11420. */
  11421. addExcludedMesh(mesh: Mesh): void;
  11422. /**
  11423. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11424. * @param mesh The mesh to highlight
  11425. */
  11426. removeExcludedMesh(mesh: Mesh): void;
  11427. /**
  11428. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11429. * @param mesh mesh to test
  11430. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11431. */
  11432. hasMesh(mesh: AbstractMesh): boolean;
  11433. /**
  11434. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11435. * @param mesh The mesh to highlight
  11436. * @param color The color of the highlight
  11437. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11438. */
  11439. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11440. /**
  11441. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11442. * @param mesh The mesh to highlight
  11443. */
  11444. removeMesh(mesh: Mesh): void;
  11445. /**
  11446. * Force the stencil to the normal expected value for none glowing parts
  11447. */
  11448. private _defaultStencilReference;
  11449. /**
  11450. * Free any resources and references associated to a mesh.
  11451. * Internal use
  11452. * @param mesh The mesh to free.
  11453. */
  11454. _disposeMesh(mesh: Mesh): void;
  11455. /**
  11456. * Dispose the highlight layer and free resources.
  11457. */
  11458. dispose(): void;
  11459. /**
  11460. * Gets the class name of the effect layer
  11461. * @returns the string with the class name of the effect layer
  11462. */
  11463. getClassName(): string;
  11464. /**
  11465. * Serializes this Highlight layer
  11466. * @returns a serialized Highlight layer object
  11467. */
  11468. serialize(): any;
  11469. /**
  11470. * Creates a Highlight layer from parsed Highlight layer data
  11471. * @param parsedHightlightLayer defines the Highlight layer data
  11472. * @param scene defines the current scene
  11473. * @param rootUrl defines the root URL containing the Highlight layer information
  11474. * @returns a parsed Highlight layer
  11475. */
  11476. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11477. }
  11478. }
  11479. declare module BABYLON {
  11480. class Layer {
  11481. name: string;
  11482. texture: Nullable<Texture>;
  11483. isBackground: boolean;
  11484. color: Color4;
  11485. scale: Vector2;
  11486. offset: Vector2;
  11487. alphaBlendingMode: number;
  11488. alphaTest: boolean;
  11489. layerMask: number;
  11490. private _scene;
  11491. private _vertexBuffers;
  11492. private _indexBuffer;
  11493. private _effect;
  11494. private _alphaTestEffect;
  11495. /**
  11496. * An event triggered when the layer is disposed.
  11497. */
  11498. onDisposeObservable: Observable<Layer>;
  11499. private _onDisposeObserver;
  11500. onDispose: () => void;
  11501. /**
  11502. * An event triggered before rendering the scene
  11503. */
  11504. onBeforeRenderObservable: Observable<Layer>;
  11505. private _onBeforeRenderObserver;
  11506. onBeforeRender: () => void;
  11507. /**
  11508. * An event triggered after rendering the scene
  11509. */
  11510. onAfterRenderObservable: Observable<Layer>;
  11511. private _onAfterRenderObserver;
  11512. onAfterRender: () => void;
  11513. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11514. private _createIndexBuffer;
  11515. _rebuild(): void;
  11516. render(): void;
  11517. dispose(): void;
  11518. }
  11519. }
  11520. declare module BABYLON {
  11521. interface AbstractScene {
  11522. /**
  11523. * The list of layers (background and foreground) of the scene
  11524. */
  11525. layers: Array<Layer>;
  11526. }
  11527. /**
  11528. * Defines the layer scene component responsible to manage any layers
  11529. * in a given scene.
  11530. */
  11531. class LayerSceneComponent implements ISceneComponent {
  11532. /**
  11533. * The component name helpfull to identify the component in the list of scene components.
  11534. */
  11535. readonly name: string;
  11536. /**
  11537. * The scene the component belongs to.
  11538. */
  11539. scene: Scene;
  11540. private _engine;
  11541. /**
  11542. * Creates a new instance of the component for the given scene
  11543. * @param scene Defines the scene to register the component in
  11544. */
  11545. constructor(scene: Scene);
  11546. /**
  11547. * Registers the component in a given scene
  11548. */
  11549. register(): void;
  11550. /**
  11551. * Rebuilds the elements related to this component in case of
  11552. * context lost for instance.
  11553. */
  11554. rebuild(): void;
  11555. /**
  11556. * Disposes the component and the associated ressources.
  11557. */
  11558. dispose(): void;
  11559. private _draw;
  11560. private _drawBackground;
  11561. private _drawForeground;
  11562. }
  11563. }
  11564. declare module BABYLON {
  11565. class LensFlare {
  11566. size: number;
  11567. position: number;
  11568. color: Color3;
  11569. texture: Nullable<Texture>;
  11570. alphaMode: number;
  11571. private _system;
  11572. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11573. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11574. dispose(): void;
  11575. }
  11576. }
  11577. declare module BABYLON {
  11578. class LensFlareSystem {
  11579. name: string;
  11580. lensFlares: LensFlare[];
  11581. borderLimit: number;
  11582. viewportBorder: number;
  11583. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11584. layerMask: number;
  11585. id: string;
  11586. private _scene;
  11587. private _emitter;
  11588. private _vertexBuffers;
  11589. private _indexBuffer;
  11590. private _effect;
  11591. private _positionX;
  11592. private _positionY;
  11593. private _isEnabled;
  11594. constructor(name: string, emitter: any, scene: Scene);
  11595. isEnabled: boolean;
  11596. getScene(): Scene;
  11597. getEmitter(): any;
  11598. setEmitter(newEmitter: any): void;
  11599. getEmitterPosition(): Vector3;
  11600. computeEffectivePosition(globalViewport: Viewport): boolean;
  11601. _isVisible(): boolean;
  11602. render(): boolean;
  11603. dispose(): void;
  11604. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11605. serialize(): any;
  11606. }
  11607. }
  11608. declare module BABYLON {
  11609. interface AbstractScene {
  11610. /**
  11611. * The list of lens flare system added to the scene
  11612. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11613. */
  11614. lensFlareSystems: Array<LensFlareSystem>;
  11615. /**
  11616. * Removes the given lens flare system from this scene.
  11617. * @param toRemove The lens flare system to remove
  11618. * @returns The index of the removed lens flare system
  11619. */
  11620. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11621. /**
  11622. * Adds the given lens flare system to this scene
  11623. * @param newLensFlareSystem The lens flare system to add
  11624. */
  11625. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11626. /**
  11627. * Gets a lens flare system using its name
  11628. * @param name defines the name to look for
  11629. * @returns the lens flare system or null if not found
  11630. */
  11631. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11632. /**
  11633. * Gets a lens flare system using its id
  11634. * @param id defines the id to look for
  11635. * @returns the lens flare system or null if not found
  11636. */
  11637. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11638. }
  11639. /**
  11640. * Defines the lens flare scene component responsible to manage any lens flares
  11641. * in a given scene.
  11642. */
  11643. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11644. /**
  11645. * The component name helpfull to identify the component in the list of scene components.
  11646. */
  11647. readonly name: string;
  11648. /**
  11649. * The scene the component belongs to.
  11650. */
  11651. scene: Scene;
  11652. /**
  11653. * Creates a new instance of the component for the given scene
  11654. * @param scene Defines the scene to register the component in
  11655. */
  11656. constructor(scene: Scene);
  11657. /**
  11658. * Registers the component in a given scene
  11659. */
  11660. register(): void;
  11661. /**
  11662. * Rebuilds the elements related to this component in case of
  11663. * context lost for instance.
  11664. */
  11665. rebuild(): void;
  11666. /**
  11667. * Adds all the element from the container to the scene
  11668. * @param container the container holding the elements
  11669. */
  11670. addFromContainer(container: AbstractScene): void;
  11671. /**
  11672. * Removes all the elements in the container from the scene
  11673. * @param container contains the elements to remove
  11674. */
  11675. removeFromContainer(container: AbstractScene): void;
  11676. /**
  11677. * Serializes the component data to the specified json object
  11678. * @param serializationObject The object to serialize to
  11679. */
  11680. serialize(serializationObject: any): void;
  11681. /**
  11682. * Disposes the component and the associated ressources.
  11683. */
  11684. dispose(): void;
  11685. private _draw;
  11686. }
  11687. }
  11688. declare module BABYLON {
  11689. interface ILoadingScreen {
  11690. displayLoadingUI: () => void;
  11691. hideLoadingUI: () => void;
  11692. loadingUIBackgroundColor: string;
  11693. loadingUIText: string;
  11694. }
  11695. class DefaultLoadingScreen implements ILoadingScreen {
  11696. private _renderingCanvas;
  11697. private _loadingText;
  11698. private _loadingDivBackgroundColor;
  11699. private _loadingDiv;
  11700. private _loadingTextDiv;
  11701. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11702. displayLoadingUI(): void;
  11703. hideLoadingUI(): void;
  11704. loadingUIText: string;
  11705. loadingUIBackgroundColor: string;
  11706. private _resizeLoadingUI;
  11707. }
  11708. }
  11709. declare module BABYLON {
  11710. class SceneLoaderProgressEvent {
  11711. readonly lengthComputable: boolean;
  11712. readonly loaded: number;
  11713. readonly total: number;
  11714. constructor(lengthComputable: boolean, loaded: number, total: number);
  11715. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11716. }
  11717. interface ISceneLoaderPluginExtensions {
  11718. [extension: string]: {
  11719. isBinary: boolean;
  11720. };
  11721. }
  11722. interface ISceneLoaderPluginFactory {
  11723. name: string;
  11724. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11725. canDirectLoad?: (data: string) => boolean;
  11726. }
  11727. interface ISceneLoaderPlugin {
  11728. /**
  11729. * The friendly name of this plugin.
  11730. */
  11731. name: string;
  11732. /**
  11733. * The file extensions supported by this plugin.
  11734. */
  11735. extensions: string | ISceneLoaderPluginExtensions;
  11736. /**
  11737. * Import meshes into a scene.
  11738. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11739. * @param scene The scene to import into
  11740. * @param data The data to import
  11741. * @param rootUrl The root url for scene and resources
  11742. * @param meshes The meshes array to import into
  11743. * @param particleSystems The particle systems array to import into
  11744. * @param skeletons The skeletons array to import into
  11745. * @param onError The callback when import fails
  11746. * @returns True if successful or false otherwise
  11747. */
  11748. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11749. /**
  11750. * Load into a scene.
  11751. * @param scene The scene to load into
  11752. * @param data The data to import
  11753. * @param rootUrl The root url for scene and resources
  11754. * @param onError The callback when import fails
  11755. * @returns true if successful or false otherwise
  11756. */
  11757. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11758. /**
  11759. * The callback that returns true if the data can be directly loaded.
  11760. */
  11761. canDirectLoad?: (data: string) => boolean;
  11762. /**
  11763. * The callback that allows custom handling of the root url based on the response url.
  11764. */
  11765. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11766. /**
  11767. * Load into an asset container.
  11768. * @param scene The scene to load into
  11769. * @param data The data to import
  11770. * @param rootUrl The root url for scene and resources
  11771. * @param onError The callback when import fails
  11772. * @returns The loaded asset container
  11773. */
  11774. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11775. }
  11776. interface ISceneLoaderPluginAsync {
  11777. /**
  11778. * The friendly name of this plugin.
  11779. */
  11780. name: string;
  11781. /**
  11782. * The file extensions supported by this plugin.
  11783. */
  11784. extensions: string | ISceneLoaderPluginExtensions;
  11785. /**
  11786. * Import meshes into a scene.
  11787. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11788. * @param scene The scene to import into
  11789. * @param data The data to import
  11790. * @param rootUrl The root url for scene and resources
  11791. * @param onProgress The callback when the load progresses
  11792. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11793. */
  11794. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11795. meshes: AbstractMesh[];
  11796. particleSystems: IParticleSystem[];
  11797. skeletons: Skeleton[];
  11798. animationGroups: AnimationGroup[];
  11799. }>;
  11800. /**
  11801. * Load into a scene.
  11802. * @param scene The scene to load into
  11803. * @param data The data to import
  11804. * @param rootUrl The root url for scene and resources
  11805. * @param onProgress The callback when the load progresses
  11806. * @returns Nothing
  11807. */
  11808. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11809. /**
  11810. * The callback that returns true if the data can be directly loaded.
  11811. */
  11812. canDirectLoad?: (data: string) => boolean;
  11813. /**
  11814. * The callback that allows custom handling of the root url based on the response url.
  11815. */
  11816. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11817. /**
  11818. * Load into an asset container.
  11819. * @param scene The scene to load into
  11820. * @param data The data to import
  11821. * @param rootUrl The root url for scene and resources
  11822. * @param onProgress The callback when the load progresses
  11823. * @returns The loaded asset container
  11824. */
  11825. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  11826. }
  11827. class SceneLoader {
  11828. private static _ForceFullSceneLoadingForIncremental;
  11829. private static _ShowLoadingScreen;
  11830. private static _CleanBoneMatrixWeights;
  11831. static readonly NO_LOGGING: number;
  11832. static readonly MINIMAL_LOGGING: number;
  11833. static readonly SUMMARY_LOGGING: number;
  11834. static readonly DETAILED_LOGGING: number;
  11835. private static _loggingLevel;
  11836. static ForceFullSceneLoadingForIncremental: boolean;
  11837. static ShowLoadingScreen: boolean;
  11838. static loggingLevel: number;
  11839. static CleanBoneMatrixWeights: boolean;
  11840. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11841. private static _registeredPlugins;
  11842. private static _getDefaultPlugin;
  11843. private static _getPluginForExtension;
  11844. private static _getPluginForDirectLoad;
  11845. private static _getPluginForFilename;
  11846. private static _getDirectLoad;
  11847. private static _loadData;
  11848. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  11849. static IsPluginForExtensionAvailable(extension: string): boolean;
  11850. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  11851. /**
  11852. * Import meshes into a scene
  11853. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11854. * @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)
  11855. * @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)
  11856. * @param scene the instance of BABYLON.Scene to append to
  11857. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  11858. * @param onProgress a callback with a progress event for each file being loaded
  11859. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11860. * @param pluginExtension the extension used to determine the plugin
  11861. * @returns The loaded plugin
  11862. */
  11863. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11864. /**
  11865. * Import meshes into a scene
  11866. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11867. * @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)
  11868. * @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)
  11869. * @param scene the instance of BABYLON.Scene to append to
  11870. * @param onProgress a callback with a progress event for each file being loaded
  11871. * @param pluginExtension the extension used to determine the plugin
  11872. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  11873. */
  11874. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  11875. meshes: AbstractMesh[];
  11876. particleSystems: IParticleSystem[];
  11877. skeletons: Skeleton[];
  11878. animationGroups: AnimationGroup[];
  11879. }>;
  11880. /**
  11881. * Load a scene
  11882. * @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)
  11883. * @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)
  11884. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11885. * @param onSuccess a callback with the scene when import succeeds
  11886. * @param onProgress a callback with a progress event for each file being loaded
  11887. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11888. * @param pluginExtension the extension used to determine the plugin
  11889. * @returns The loaded plugin
  11890. */
  11891. 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>;
  11892. /**
  11893. * Load a scene
  11894. * @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)
  11895. * @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)
  11896. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11897. * @param onProgress a callback with a progress event for each file being loaded
  11898. * @param pluginExtension the extension used to determine the plugin
  11899. * @returns The loaded scene
  11900. */
  11901. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11902. /**
  11903. * Append a scene
  11904. * @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)
  11905. * @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)
  11906. * @param scene is the instance of BABYLON.Scene to append to
  11907. * @param onSuccess a callback with the scene when import succeeds
  11908. * @param onProgress a callback with a progress event for each file being loaded
  11909. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11910. * @param pluginExtension the extension used to determine the plugin
  11911. * @returns The loaded plugin
  11912. */
  11913. 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>;
  11914. /**
  11915. * Append a scene
  11916. * @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)
  11917. * @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)
  11918. * @param scene is the instance of BABYLON.Scene to append to
  11919. * @param onProgress a callback with a progress event for each file being loaded
  11920. * @param pluginExtension the extension used to determine the plugin
  11921. * @returns The given scene
  11922. */
  11923. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11924. /**
  11925. * Load a scene into an asset container
  11926. * @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)
  11927. * @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)
  11928. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  11929. * @param onSuccess a callback with the scene when import succeeds
  11930. * @param onProgress a callback with a progress event for each file being loaded
  11931. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11932. * @param pluginExtension the extension used to determine the plugin
  11933. * @returns The loaded plugin
  11934. */
  11935. 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>;
  11936. /**
  11937. * Load a scene into an asset container
  11938. * @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)
  11939. * @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)
  11940. * @param scene is the instance of BABYLON.Scene to append to
  11941. * @param onProgress a callback with a progress event for each file being loaded
  11942. * @param pluginExtension the extension used to determine the plugin
  11943. * @returns The loaded asset container
  11944. */
  11945. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  11946. }
  11947. }
  11948. declare module BABYLON {
  11949. /**
  11950. * A directional light is defined by a direction (what a surprise!).
  11951. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11952. * 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.
  11953. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11954. */
  11955. class DirectionalLight extends ShadowLight {
  11956. private _shadowFrustumSize;
  11957. /**
  11958. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11959. */
  11960. /**
  11961. * Specifies a fix frustum size for the shadow generation.
  11962. */
  11963. shadowFrustumSize: number;
  11964. private _shadowOrthoScale;
  11965. /**
  11966. * Gets the shadow projection scale against the optimal computed one.
  11967. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11968. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11969. */
  11970. /**
  11971. * Sets the shadow projection scale against the optimal computed one.
  11972. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11973. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11974. */
  11975. shadowOrthoScale: number;
  11976. /**
  11977. * Automatically compute the projection matrix to best fit (including all the casters)
  11978. * on each frame.
  11979. */
  11980. autoUpdateExtends: boolean;
  11981. private _orthoLeft;
  11982. private _orthoRight;
  11983. private _orthoTop;
  11984. private _orthoBottom;
  11985. /**
  11986. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11987. * The directional light is emitted from everywhere in the given direction.
  11988. * It can cast shawdows.
  11989. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11990. * @param name The friendly name of the light
  11991. * @param direction The direction of the light
  11992. * @param scene The scene the light belongs to
  11993. */
  11994. constructor(name: string, direction: Vector3, scene: Scene);
  11995. /**
  11996. * Returns the string "DirectionalLight".
  11997. * @return The class name
  11998. */
  11999. getClassName(): string;
  12000. /**
  12001. * Returns the integer 1.
  12002. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12003. */
  12004. getTypeID(): number;
  12005. /**
  12006. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  12007. * Returns the DirectionalLight Shadow projection matrix.
  12008. */
  12009. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12010. /**
  12011. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  12012. * Returns the DirectionalLight Shadow projection matrix.
  12013. */
  12014. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  12015. /**
  12016. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  12017. * Returns the DirectionalLight Shadow projection matrix.
  12018. */
  12019. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12020. protected _buildUniformLayout(): void;
  12021. /**
  12022. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  12023. * @param effect The effect to update
  12024. * @param lightIndex The index of the light in the effect to update
  12025. * @returns The directional light
  12026. */
  12027. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  12028. /**
  12029. * Gets the minZ used for shadow according to both the scene and the light.
  12030. *
  12031. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12032. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12033. * @param activeCamera The camera we are returning the min for
  12034. * @returns the depth min z
  12035. */
  12036. getDepthMinZ(activeCamera: Camera): number;
  12037. /**
  12038. * Gets the maxZ used for shadow according to both the scene and the light.
  12039. *
  12040. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12041. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12042. * @param activeCamera The camera we are returning the max for
  12043. * @returns the depth max z
  12044. */
  12045. getDepthMaxZ(activeCamera: Camera): number;
  12046. /**
  12047. * Prepares the list of defines specific to the light type.
  12048. * @param defines the list of defines
  12049. * @param lightIndex defines the index of the light for the effect
  12050. */
  12051. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12052. }
  12053. }
  12054. declare module BABYLON {
  12055. /**
  12056. * The HemisphericLight simulates the ambient environment light,
  12057. * so the passed direction is the light reflection direction, not the incoming direction.
  12058. */
  12059. class HemisphericLight extends Light {
  12060. /**
  12061. * The groundColor is the light in the opposite direction to the one specified during creation.
  12062. * 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.
  12063. */
  12064. groundColor: Color3;
  12065. /**
  12066. * The light reflection direction, not the incoming direction.
  12067. */
  12068. direction: Vector3;
  12069. private _worldMatrix;
  12070. /**
  12071. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12072. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12073. * The HemisphericLight can't cast shadows.
  12074. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12075. * @param name The friendly name of the light
  12076. * @param direction The direction of the light reflection
  12077. * @param scene The scene the light belongs to
  12078. */
  12079. constructor(name: string, direction: Vector3, scene: Scene);
  12080. protected _buildUniformLayout(): void;
  12081. /**
  12082. * Returns the string "HemisphericLight".
  12083. * @return The class name
  12084. */
  12085. getClassName(): string;
  12086. /**
  12087. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12088. * Returns the updated direction.
  12089. * @param target The target the direction should point to
  12090. * @return The computed direction
  12091. */
  12092. setDirectionToTarget(target: Vector3): Vector3;
  12093. /**
  12094. * Returns the shadow generator associated to the light.
  12095. * @returns Always null for hemispheric lights because it does not support shadows.
  12096. */
  12097. getShadowGenerator(): Nullable<ShadowGenerator>;
  12098. /**
  12099. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12100. * @param effect The effect to update
  12101. * @param lightIndex The index of the light in the effect to update
  12102. * @returns The hemispheric light
  12103. */
  12104. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12105. /**
  12106. * @hidden internal use only.
  12107. */
  12108. _getWorldMatrix(): Matrix;
  12109. /**
  12110. * Returns the integer 3.
  12111. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12112. */
  12113. getTypeID(): number;
  12114. /**
  12115. * Prepares the list of defines specific to the light type.
  12116. * @param defines the list of defines
  12117. * @param lightIndex defines the index of the light for the effect
  12118. */
  12119. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12120. }
  12121. }
  12122. declare module BABYLON {
  12123. /**
  12124. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  12125. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  12126. * 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.
  12127. */
  12128. abstract class Light extends Node {
  12129. /**
  12130. * Falloff Default: light is falling off following the material specification:
  12131. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  12132. */
  12133. static readonly FALLOFF_DEFAULT: number;
  12134. /**
  12135. * Falloff Physical: light is falling off following the inverse squared distance law.
  12136. */
  12137. static readonly FALLOFF_PHYSICAL: number;
  12138. /**
  12139. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  12140. * to enhance interoperability with other engines.
  12141. */
  12142. static readonly FALLOFF_GLTF: number;
  12143. /**
  12144. * Falloff Standard: light is falling off like in the standard material
  12145. * to enhance interoperability with other materials.
  12146. */
  12147. static readonly FALLOFF_STANDARD: number;
  12148. /**
  12149. * If every light affecting the material is in this lightmapMode,
  12150. * material.lightmapTexture adds or multiplies
  12151. * (depends on material.useLightmapAsShadowmap)
  12152. * after every other light calculations.
  12153. */
  12154. static readonly LIGHTMAP_DEFAULT: number;
  12155. /**
  12156. * material.lightmapTexture as only diffuse lighting from this light
  12157. * adds only specular lighting from this light
  12158. * adds dynamic shadows
  12159. */
  12160. static readonly LIGHTMAP_SPECULAR: number;
  12161. /**
  12162. * material.lightmapTexture as only lighting
  12163. * no light calculation from this light
  12164. * only adds dynamic shadows from this light
  12165. */
  12166. static readonly LIGHTMAP_SHADOWSONLY: number;
  12167. /**
  12168. * Each light type uses the default quantity according to its type:
  12169. * point/spot lights use luminous intensity
  12170. * directional lights use illuminance
  12171. */
  12172. static readonly INTENSITYMODE_AUTOMATIC: number;
  12173. /**
  12174. * lumen (lm)
  12175. */
  12176. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12177. /**
  12178. * candela (lm/sr)
  12179. */
  12180. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12181. /**
  12182. * lux (lm/m^2)
  12183. */
  12184. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12185. /**
  12186. * nit (cd/m^2)
  12187. */
  12188. static readonly INTENSITYMODE_LUMINANCE: number;
  12189. /**
  12190. * Light type const id of the point light.
  12191. */
  12192. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12193. /**
  12194. * Light type const id of the directional light.
  12195. */
  12196. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12197. /**
  12198. * Light type const id of the spot light.
  12199. */
  12200. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12201. /**
  12202. * Light type const id of the hemispheric light.
  12203. */
  12204. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12205. /**
  12206. * Diffuse gives the basic color to an object.
  12207. */
  12208. diffuse: Color3;
  12209. /**
  12210. * Specular produces a highlight color on an object.
  12211. * Note: This is note affecting PBR materials.
  12212. */
  12213. specular: Color3;
  12214. /**
  12215. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12216. * falling off base on range or angle.
  12217. * This can be set to any values in Light.FALLOFF_x.
  12218. *
  12219. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12220. * other types of materials.
  12221. */
  12222. falloffType: number;
  12223. /**
  12224. * Strength of the light.
  12225. * Note: By default it is define in the framework own unit.
  12226. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12227. */
  12228. intensity: number;
  12229. private _range;
  12230. protected _inverseSquaredRange: number;
  12231. /**
  12232. * Defines how far from the source the light is impacting in scene units.
  12233. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12234. */
  12235. /**
  12236. * Defines how far from the source the light is impacting in scene units.
  12237. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12238. */
  12239. range: number;
  12240. /**
  12241. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12242. * of light.
  12243. */
  12244. private _photometricScale;
  12245. private _intensityMode;
  12246. /**
  12247. * Gets the photometric scale used to interpret the intensity.
  12248. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12249. */
  12250. /**
  12251. * Sets the photometric scale used to interpret the intensity.
  12252. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12253. */
  12254. intensityMode: number;
  12255. private _radius;
  12256. /**
  12257. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12258. */
  12259. /**
  12260. * sets the light radius used by PBR Materials to simulate soft area lights.
  12261. */
  12262. radius: number;
  12263. private _renderPriority;
  12264. /**
  12265. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12266. * exceeding the number allowed of the materials.
  12267. */
  12268. renderPriority: number;
  12269. private _shadowEnabled;
  12270. /**
  12271. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12272. * the current shadow generator.
  12273. */
  12274. /**
  12275. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12276. * the current shadow generator.
  12277. */
  12278. shadowEnabled: boolean;
  12279. private _includedOnlyMeshes;
  12280. /**
  12281. * Gets the only meshes impacted by this light.
  12282. */
  12283. /**
  12284. * Sets the only meshes impacted by this light.
  12285. */
  12286. includedOnlyMeshes: AbstractMesh[];
  12287. private _excludedMeshes;
  12288. /**
  12289. * Gets the meshes not impacted by this light.
  12290. */
  12291. /**
  12292. * Sets the meshes not impacted by this light.
  12293. */
  12294. excludedMeshes: AbstractMesh[];
  12295. private _excludeWithLayerMask;
  12296. /**
  12297. * Gets the layer id use to find what meshes are not impacted by the light.
  12298. * Inactive if 0
  12299. */
  12300. /**
  12301. * Sets the layer id use to find what meshes are not impacted by the light.
  12302. * Inactive if 0
  12303. */
  12304. excludeWithLayerMask: number;
  12305. private _includeOnlyWithLayerMask;
  12306. /**
  12307. * Gets the layer id use to find what meshes are impacted by the light.
  12308. * Inactive if 0
  12309. */
  12310. /**
  12311. * Sets the layer id use to find what meshes are impacted by the light.
  12312. * Inactive if 0
  12313. */
  12314. includeOnlyWithLayerMask: number;
  12315. private _lightmapMode;
  12316. /**
  12317. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12318. */
  12319. /**
  12320. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12321. */
  12322. lightmapMode: number;
  12323. private _parentedWorldMatrix;
  12324. /**
  12325. * Shadow generator associted to the light.
  12326. * Internal use only.
  12327. */
  12328. _shadowGenerator: Nullable<IShadowGenerator>;
  12329. /**
  12330. * @hidden Internal use only.
  12331. */
  12332. _excludedMeshesIds: string[];
  12333. /**
  12334. * @hidden Internal use only.
  12335. */
  12336. _includedOnlyMeshesIds: string[];
  12337. /**
  12338. * The current light unifom buffer.
  12339. * @hidden Internal use only.
  12340. */
  12341. _uniformBuffer: UniformBuffer;
  12342. /**
  12343. * Creates a Light object in the scene.
  12344. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12345. * @param name The firendly name of the light
  12346. * @param scene The scene the light belongs too
  12347. */
  12348. constructor(name: string, scene: Scene);
  12349. protected abstract _buildUniformLayout(): void;
  12350. /**
  12351. * Sets the passed Effect "effect" with the Light information.
  12352. * @param effect The effect to update
  12353. * @param lightIndex The index of the light in the effect to update
  12354. * @returns The light
  12355. */
  12356. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12357. /**
  12358. * @hidden internal use only.
  12359. */
  12360. abstract _getWorldMatrix(): Matrix;
  12361. /**
  12362. * Returns the string "Light".
  12363. * @returns the class name
  12364. */
  12365. getClassName(): string;
  12366. /**
  12367. * Converts the light information to a readable string for debug purpose.
  12368. * @param fullDetails Supports for multiple levels of logging within scene loading
  12369. * @returns the human readable light info
  12370. */
  12371. toString(fullDetails?: boolean): string;
  12372. /**
  12373. * Set the enabled state of this node.
  12374. * @param value - the new enabled state
  12375. */
  12376. setEnabled(value: boolean): void;
  12377. /**
  12378. * Returns the Light associated shadow generator if any.
  12379. * @return the associated shadow generator.
  12380. */
  12381. getShadowGenerator(): Nullable<IShadowGenerator>;
  12382. /**
  12383. * Returns a Vector3, the absolute light position in the World.
  12384. * @returns the world space position of the light
  12385. */
  12386. getAbsolutePosition(): Vector3;
  12387. /**
  12388. * Specifies if the light will affect the passed mesh.
  12389. * @param mesh The mesh to test against the light
  12390. * @return true the mesh is affected otherwise, false.
  12391. */
  12392. canAffectMesh(mesh: AbstractMesh): boolean;
  12393. /**
  12394. * Computes and Returns the light World matrix.
  12395. * @returns the world matrix
  12396. */
  12397. getWorldMatrix(): Matrix;
  12398. /**
  12399. * Sort function to order lights for rendering.
  12400. * @param a First Light object to compare to second.
  12401. * @param b Second Light object to compare first.
  12402. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12403. */
  12404. static CompareLightsPriority(a: Light, b: Light): number;
  12405. /**
  12406. * Releases resources associated with this node.
  12407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12409. */
  12410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12411. /**
  12412. * Returns the light type ID (integer).
  12413. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12414. */
  12415. getTypeID(): number;
  12416. /**
  12417. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12418. * @returns the scaled intensity in intensity mode unit
  12419. */
  12420. getScaledIntensity(): number;
  12421. /**
  12422. * Returns a new Light object, named "name", from the current one.
  12423. * @param name The name of the cloned light
  12424. * @returns the new created light
  12425. */
  12426. clone(name: string): Nullable<Light>;
  12427. /**
  12428. * Serializes the current light into a Serialization object.
  12429. * @returns the serialized object.
  12430. */
  12431. serialize(): any;
  12432. /**
  12433. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12434. * This new light is named "name" and added to the passed scene.
  12435. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12436. * @param name The friendly name of the light
  12437. * @param scene The scene the new light will belong to
  12438. * @returns the constructor function
  12439. */
  12440. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12441. /**
  12442. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12443. * @param parsedLight The JSON representation of the light
  12444. * @param scene The scene to create the parsed light in
  12445. * @returns the created light after parsing
  12446. */
  12447. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12448. private _hookArrayForExcluded;
  12449. private _hookArrayForIncludedOnly;
  12450. private _resyncMeshes;
  12451. /**
  12452. * Forces the meshes to update their light related information in their rendering used effects
  12453. * @hidden Internal Use Only
  12454. */
  12455. _markMeshesAsLightDirty(): void;
  12456. /**
  12457. * Recomputes the cached photometric scale if needed.
  12458. */
  12459. private _computePhotometricScale;
  12460. /**
  12461. * Returns the Photometric Scale according to the light type and intensity mode.
  12462. */
  12463. private _getPhotometricScale;
  12464. /**
  12465. * Reorder the light in the scene according to their defined priority.
  12466. * @hidden Internal Use Only
  12467. */
  12468. _reorderLightsInScene(): void;
  12469. /**
  12470. * Prepares the list of defines specific to the light type.
  12471. * @param defines the list of defines
  12472. * @param lightIndex defines the index of the light for the effect
  12473. */
  12474. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12475. }
  12476. }
  12477. declare module BABYLON {
  12478. /**
  12479. * A point light is a light defined by an unique point in world space.
  12480. * The light is emitted in every direction from this point.
  12481. * A good example of a point light is a standard light bulb.
  12482. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12483. */
  12484. class PointLight extends ShadowLight {
  12485. private _shadowAngle;
  12486. /**
  12487. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12488. * This specifies what angle the shadow will use to be created.
  12489. *
  12490. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12491. */
  12492. /**
  12493. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12494. * This specifies what angle the shadow will use to be created.
  12495. *
  12496. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12497. */
  12498. shadowAngle: number;
  12499. /**
  12500. * Gets the direction if it has been set.
  12501. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12502. */
  12503. /**
  12504. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12505. */
  12506. direction: Vector3;
  12507. /**
  12508. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12509. * A PointLight emits the light in every direction.
  12510. * It can cast shadows.
  12511. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12512. * ```javascript
  12513. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12514. * ```
  12515. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12516. * @param name The light friendly name
  12517. * @param position The position of the point light in the scene
  12518. * @param scene The scene the lights belongs to
  12519. */
  12520. constructor(name: string, position: Vector3, scene: Scene);
  12521. /**
  12522. * Returns the string "PointLight"
  12523. * @returns the class name
  12524. */
  12525. getClassName(): string;
  12526. /**
  12527. * Returns the integer 0.
  12528. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12529. */
  12530. getTypeID(): number;
  12531. /**
  12532. * Specifies wether or not the shadowmap should be a cube texture.
  12533. * @returns true if the shadowmap needs to be a cube texture.
  12534. */
  12535. needCube(): boolean;
  12536. /**
  12537. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12538. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12539. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12540. */
  12541. getShadowDirection(faceIndex?: number): Vector3;
  12542. /**
  12543. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12544. * - fov = PI / 2
  12545. * - aspect ratio : 1.0
  12546. * - z-near and far equal to the active camera minZ and maxZ.
  12547. * Returns the PointLight.
  12548. */
  12549. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12550. protected _buildUniformLayout(): void;
  12551. /**
  12552. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12553. * @param effect The effect to update
  12554. * @param lightIndex The index of the light in the effect to update
  12555. * @returns The point light
  12556. */
  12557. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12558. /**
  12559. * Prepares the list of defines specific to the light type.
  12560. * @param defines the list of defines
  12561. * @param lightIndex defines the index of the light for the effect
  12562. */
  12563. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12564. }
  12565. }
  12566. declare module BABYLON {
  12567. /**
  12568. * Interface describing all the common properties and methods a shadow light needs to implement.
  12569. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12570. * as well as binding the different shadow properties to the effects.
  12571. */
  12572. interface IShadowLight extends Light {
  12573. /**
  12574. * The light id in the scene (used in scene.findLighById for instance)
  12575. */
  12576. id: string;
  12577. /**
  12578. * The position the shdow will be casted from.
  12579. */
  12580. position: Vector3;
  12581. /**
  12582. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12583. */
  12584. direction: Vector3;
  12585. /**
  12586. * The transformed position. Position of the light in world space taking parenting in account.
  12587. */
  12588. transformedPosition: Vector3;
  12589. /**
  12590. * The transformed direction. Direction of the light in world space taking parenting in account.
  12591. */
  12592. transformedDirection: Vector3;
  12593. /**
  12594. * The friendly name of the light in the scene.
  12595. */
  12596. name: string;
  12597. /**
  12598. * Defines the shadow projection clipping minimum z value.
  12599. */
  12600. shadowMinZ: number;
  12601. /**
  12602. * Defines the shadow projection clipping maximum z value.
  12603. */
  12604. shadowMaxZ: number;
  12605. /**
  12606. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12607. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12608. */
  12609. computeTransformedInformation(): boolean;
  12610. /**
  12611. * Gets the scene the light belongs to.
  12612. * @returns The scene
  12613. */
  12614. getScene(): Scene;
  12615. /**
  12616. * Callback defining a custom Projection Matrix Builder.
  12617. * This can be used to override the default projection matrix computation.
  12618. */
  12619. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12620. /**
  12621. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12622. * @param matrix The materix to updated with the projection information
  12623. * @param viewMatrix The transform matrix of the light
  12624. * @param renderList The list of mesh to render in the map
  12625. * @returns The current light
  12626. */
  12627. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12628. /**
  12629. * Gets the current depth scale used in ESM.
  12630. * @returns The scale
  12631. */
  12632. getDepthScale(): number;
  12633. /**
  12634. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12635. * @returns true if a cube texture needs to be use
  12636. */
  12637. needCube(): boolean;
  12638. /**
  12639. * Detects if the projection matrix requires to be recomputed this frame.
  12640. * @returns true if it requires to be recomputed otherwise, false.
  12641. */
  12642. needProjectionMatrixCompute(): boolean;
  12643. /**
  12644. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12645. */
  12646. forceProjectionMatrixCompute(): void;
  12647. /**
  12648. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12649. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12650. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12651. */
  12652. getShadowDirection(faceIndex?: number): Vector3;
  12653. /**
  12654. * Gets the minZ used for shadow according to both the scene and the light.
  12655. * @param activeCamera The camera we are returning the min for
  12656. * @returns the depth min z
  12657. */
  12658. getDepthMinZ(activeCamera: Camera): number;
  12659. /**
  12660. * Gets the maxZ used for shadow according to both the scene and the light.
  12661. * @param activeCamera The camera we are returning the max for
  12662. * @returns the depth max z
  12663. */
  12664. getDepthMaxZ(activeCamera: Camera): number;
  12665. }
  12666. /**
  12667. * Base implementation IShadowLight
  12668. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12669. */
  12670. abstract class ShadowLight extends Light implements IShadowLight {
  12671. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12672. protected _position: Vector3;
  12673. protected _setPosition(value: Vector3): void;
  12674. /**
  12675. * Sets the position the shadow will be casted from. Also use as the light position for both
  12676. * point and spot lights.
  12677. */
  12678. /**
  12679. * Sets the position the shadow will be casted from. Also use as the light position for both
  12680. * point and spot lights.
  12681. */
  12682. position: Vector3;
  12683. protected _direction: Vector3;
  12684. protected _setDirection(value: Vector3): void;
  12685. /**
  12686. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12687. * Also use as the light direction on spot and directional lights.
  12688. */
  12689. /**
  12690. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12691. * Also use as the light direction on spot and directional lights.
  12692. */
  12693. direction: Vector3;
  12694. private _shadowMinZ;
  12695. /**
  12696. * Gets the shadow projection clipping minimum z value.
  12697. */
  12698. /**
  12699. * Sets the shadow projection clipping minimum z value.
  12700. */
  12701. shadowMinZ: number;
  12702. private _shadowMaxZ;
  12703. /**
  12704. * Sets the shadow projection clipping maximum z value.
  12705. */
  12706. /**
  12707. * Gets the shadow projection clipping maximum z value.
  12708. */
  12709. shadowMaxZ: number;
  12710. /**
  12711. * Callback defining a custom Projection Matrix Builder.
  12712. * This can be used to override the default projection matrix computation.
  12713. */
  12714. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12715. /**
  12716. * The transformed position. Position of the light in world space taking parenting in account.
  12717. */
  12718. transformedPosition: Vector3;
  12719. /**
  12720. * The transformed direction. Direction of the light in world space taking parenting in account.
  12721. */
  12722. transformedDirection: Vector3;
  12723. private _worldMatrix;
  12724. private _needProjectionMatrixCompute;
  12725. /**
  12726. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12727. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12728. */
  12729. computeTransformedInformation(): boolean;
  12730. /**
  12731. * Return the depth scale used for the shadow map.
  12732. * @returns the depth scale.
  12733. */
  12734. getDepthScale(): number;
  12735. /**
  12736. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12737. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12738. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12739. */
  12740. getShadowDirection(faceIndex?: number): Vector3;
  12741. /**
  12742. * Returns the ShadowLight absolute position in the World.
  12743. * @returns the position vector in world space
  12744. */
  12745. getAbsolutePosition(): Vector3;
  12746. /**
  12747. * Sets the ShadowLight direction toward the passed target.
  12748. * @param target The point tot target in local space
  12749. * @returns the updated ShadowLight direction
  12750. */
  12751. setDirectionToTarget(target: Vector3): Vector3;
  12752. /**
  12753. * Returns the light rotation in euler definition.
  12754. * @returns the x y z rotation in local space.
  12755. */
  12756. getRotation(): Vector3;
  12757. /**
  12758. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12759. * @returns true if a cube texture needs to be use
  12760. */
  12761. needCube(): boolean;
  12762. /**
  12763. * Detects if the projection matrix requires to be recomputed this frame.
  12764. * @returns true if it requires to be recomputed otherwise, false.
  12765. */
  12766. needProjectionMatrixCompute(): boolean;
  12767. /**
  12768. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12769. */
  12770. forceProjectionMatrixCompute(): void;
  12771. /**
  12772. * Get the world matrix of the sahdow lights.
  12773. * @hidden Internal Use Only
  12774. */
  12775. _getWorldMatrix(): Matrix;
  12776. /**
  12777. * Gets the minZ used for shadow according to both the scene and the light.
  12778. * @param activeCamera The camera we are returning the min for
  12779. * @returns the depth min z
  12780. */
  12781. getDepthMinZ(activeCamera: Camera): number;
  12782. /**
  12783. * Gets the maxZ used for shadow according to both the scene and the light.
  12784. * @param activeCamera The camera we are returning the max for
  12785. * @returns the depth max z
  12786. */
  12787. getDepthMaxZ(activeCamera: Camera): number;
  12788. /**
  12789. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12790. * @param matrix The materix to updated with the projection information
  12791. * @param viewMatrix The transform matrix of the light
  12792. * @param renderList The list of mesh to render in the map
  12793. * @returns The current light
  12794. */
  12795. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12796. }
  12797. }
  12798. declare module BABYLON {
  12799. /**
  12800. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12801. * These values define a cone of light starting from the position, emitting toward the direction.
  12802. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12803. * and the exponent defines the speed of the decay of the light with distance (reach).
  12804. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12805. */
  12806. class SpotLight extends ShadowLight {
  12807. private _angle;
  12808. private _innerAngle;
  12809. private _cosHalfAngle;
  12810. private _lightAngleScale;
  12811. private _lightAngleOffset;
  12812. /**
  12813. * Gets the cone angle of the spot light in Radians.
  12814. */
  12815. /**
  12816. * Sets the cone angle of the spot light in Radians.
  12817. */
  12818. angle: number;
  12819. /**
  12820. * Only used in gltf falloff mode, this defines the angle where
  12821. * the directional falloff will start before cutting at angle which could be seen
  12822. * as outer angle.
  12823. */
  12824. /**
  12825. * Only used in gltf falloff mode, this defines the angle where
  12826. * the directional falloff will start before cutting at angle which could be seen
  12827. * as outer angle.
  12828. */
  12829. innerAngle: number;
  12830. private _shadowAngleScale;
  12831. /**
  12832. * Allows scaling the angle of the light for shadow generation only.
  12833. */
  12834. /**
  12835. * Allows scaling the angle of the light for shadow generation only.
  12836. */
  12837. shadowAngleScale: number;
  12838. /**
  12839. * The light decay speed with the distance from the emission spot.
  12840. */
  12841. exponent: number;
  12842. private _projectionTextureMatrix;
  12843. /**
  12844. * Allows reading the projecton texture
  12845. */
  12846. readonly projectionTextureMatrix: Matrix;
  12847. protected _projectionTextureLightNear: number;
  12848. /**
  12849. * Gets the near clip of the Spotlight for texture projection.
  12850. */
  12851. /**
  12852. * Sets the near clip of the Spotlight for texture projection.
  12853. */
  12854. projectionTextureLightNear: number;
  12855. protected _projectionTextureLightFar: number;
  12856. /**
  12857. * Gets the far clip of the Spotlight for texture projection.
  12858. */
  12859. /**
  12860. * Sets the far clip of the Spotlight for texture projection.
  12861. */
  12862. projectionTextureLightFar: number;
  12863. protected _projectionTextureUpDirection: Vector3;
  12864. /**
  12865. * Gets the Up vector of the Spotlight for texture projection.
  12866. */
  12867. /**
  12868. * Sets the Up vector of the Spotlight for texture projection.
  12869. */
  12870. projectionTextureUpDirection: Vector3;
  12871. private _projectionTexture;
  12872. /**
  12873. * Gets the projection texture of the light.
  12874. */
  12875. /**
  12876. * Sets the projection texture of the light.
  12877. */
  12878. projectionTexture: Nullable<BaseTexture>;
  12879. private _projectionTextureViewLightDirty;
  12880. private _projectionTextureProjectionLightDirty;
  12881. private _projectionTextureDirty;
  12882. private _projectionTextureViewTargetVector;
  12883. private _projectionTextureViewLightMatrix;
  12884. private _projectionTextureProjectionLightMatrix;
  12885. private _projectionTextureScalingMatrix;
  12886. /**
  12887. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12888. * It can cast shadows.
  12889. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12890. * @param name The light friendly name
  12891. * @param position The position of the spot light in the scene
  12892. * @param direction The direction of the light in the scene
  12893. * @param angle The cone angle of the light in Radians
  12894. * @param exponent The light decay speed with the distance from the emission spot
  12895. * @param scene The scene the lights belongs to
  12896. */
  12897. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12898. /**
  12899. * Returns the string "SpotLight".
  12900. * @returns the class name
  12901. */
  12902. getClassName(): string;
  12903. /**
  12904. * Returns the integer 2.
  12905. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12906. */
  12907. getTypeID(): number;
  12908. /**
  12909. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12910. */
  12911. protected _setDirection(value: Vector3): void;
  12912. /**
  12913. * Overrides the position setter to recompute the projection texture view light Matrix.
  12914. */
  12915. protected _setPosition(value: Vector3): void;
  12916. /**
  12917. * 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.
  12918. * Returns the SpotLight.
  12919. */
  12920. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12921. protected _computeProjectionTextureViewLightMatrix(): void;
  12922. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12923. /**
  12924. * Main function for light texture projection matrix computing.
  12925. */
  12926. protected _computeProjectionTextureMatrix(): void;
  12927. protected _buildUniformLayout(): void;
  12928. private _computeAngleValues;
  12929. /**
  12930. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12931. * @param effect The effect to update
  12932. * @param lightIndex The index of the light in the effect to update
  12933. * @returns The spot light
  12934. */
  12935. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12936. /**
  12937. * Disposes the light and the associated resources.
  12938. */
  12939. dispose(): void;
  12940. /**
  12941. * Prepares the list of defines specific to the light type.
  12942. * @param defines the list of defines
  12943. * @param lightIndex defines the index of the light for the effect
  12944. */
  12945. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12946. }
  12947. }
  12948. declare module BABYLON {
  12949. /**
  12950. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12951. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12952. * 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;
  12953. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12954. */
  12955. class ColorCurves {
  12956. private _dirty;
  12957. private _tempColor;
  12958. private _globalCurve;
  12959. private _highlightsCurve;
  12960. private _midtonesCurve;
  12961. private _shadowsCurve;
  12962. private _positiveCurve;
  12963. private _negativeCurve;
  12964. private _globalHue;
  12965. private _globalDensity;
  12966. private _globalSaturation;
  12967. private _globalExposure;
  12968. /**
  12969. * Gets the global Hue value.
  12970. * 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).
  12971. */
  12972. /**
  12973. * Sets the global Hue value.
  12974. * 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).
  12975. */
  12976. globalHue: number;
  12977. /**
  12978. * Gets the global Density value.
  12979. * 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.
  12980. * Values less than zero provide a filter of opposite hue.
  12981. */
  12982. /**
  12983. * Sets the global Density value.
  12984. * 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.
  12985. * Values less than zero provide a filter of opposite hue.
  12986. */
  12987. globalDensity: number;
  12988. /**
  12989. * Gets the global Saturation value.
  12990. * 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.
  12991. */
  12992. /**
  12993. * Sets the global Saturation value.
  12994. * 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.
  12995. */
  12996. globalSaturation: number;
  12997. /**
  12998. * Gets the global Exposure value.
  12999. * 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.
  13000. */
  13001. /**
  13002. * Sets the global Exposure value.
  13003. * 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.
  13004. */
  13005. globalExposure: number;
  13006. private _highlightsHue;
  13007. private _highlightsDensity;
  13008. private _highlightsSaturation;
  13009. private _highlightsExposure;
  13010. /**
  13011. * Gets the highlights Hue value.
  13012. * 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).
  13013. */
  13014. /**
  13015. * Sets the highlights Hue value.
  13016. * 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).
  13017. */
  13018. highlightsHue: number;
  13019. /**
  13020. * Gets the highlights Density value.
  13021. * 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.
  13022. * Values less than zero provide a filter of opposite hue.
  13023. */
  13024. /**
  13025. * Sets the highlights Density value.
  13026. * 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.
  13027. * Values less than zero provide a filter of opposite hue.
  13028. */
  13029. highlightsDensity: number;
  13030. /**
  13031. * Gets the highlights Saturation value.
  13032. * 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.
  13033. */
  13034. /**
  13035. * Sets the highlights Saturation value.
  13036. * 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.
  13037. */
  13038. highlightsSaturation: number;
  13039. /**
  13040. * Gets the highlights Exposure value.
  13041. * 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.
  13042. */
  13043. /**
  13044. * Sets the highlights Exposure value.
  13045. * 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.
  13046. */
  13047. highlightsExposure: number;
  13048. private _midtonesHue;
  13049. private _midtonesDensity;
  13050. private _midtonesSaturation;
  13051. private _midtonesExposure;
  13052. /**
  13053. * Gets the midtones Hue value.
  13054. * 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).
  13055. */
  13056. /**
  13057. * Sets the midtones Hue value.
  13058. * 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).
  13059. */
  13060. midtonesHue: number;
  13061. /**
  13062. * Gets the midtones Density value.
  13063. * 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.
  13064. * Values less than zero provide a filter of opposite hue.
  13065. */
  13066. /**
  13067. * Sets the midtones Density value.
  13068. * 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.
  13069. * Values less than zero provide a filter of opposite hue.
  13070. */
  13071. midtonesDensity: number;
  13072. /**
  13073. * Gets the midtones Saturation value.
  13074. * 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.
  13075. */
  13076. /**
  13077. * Sets the midtones Saturation value.
  13078. * 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.
  13079. */
  13080. midtonesSaturation: number;
  13081. /**
  13082. * Gets the midtones Exposure value.
  13083. * 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.
  13084. */
  13085. /**
  13086. * Sets the midtones Exposure value.
  13087. * 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.
  13088. */
  13089. midtonesExposure: number;
  13090. private _shadowsHue;
  13091. private _shadowsDensity;
  13092. private _shadowsSaturation;
  13093. private _shadowsExposure;
  13094. /**
  13095. * Gets the shadows Hue value.
  13096. * 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).
  13097. */
  13098. /**
  13099. * Sets the shadows Hue value.
  13100. * 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).
  13101. */
  13102. shadowsHue: number;
  13103. /**
  13104. * Gets the shadows Density value.
  13105. * 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.
  13106. * Values less than zero provide a filter of opposite hue.
  13107. */
  13108. /**
  13109. * Sets the shadows Density value.
  13110. * 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.
  13111. * Values less than zero provide a filter of opposite hue.
  13112. */
  13113. shadowsDensity: number;
  13114. /**
  13115. * Gets the shadows Saturation value.
  13116. * 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.
  13117. */
  13118. /**
  13119. * Sets the shadows Saturation value.
  13120. * 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.
  13121. */
  13122. shadowsSaturation: number;
  13123. /**
  13124. * Gets the shadows Exposure value.
  13125. * 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.
  13126. */
  13127. /**
  13128. * Sets the shadows Exposure value.
  13129. * 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.
  13130. */
  13131. shadowsExposure: number;
  13132. getClassName(): string;
  13133. /**
  13134. * Binds the color curves to the shader.
  13135. * @param colorCurves The color curve to bind
  13136. * @param effect The effect to bind to
  13137. */
  13138. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  13139. /**
  13140. * Prepare the list of uniforms associated with the ColorCurves effects.
  13141. * @param uniformsList The list of uniforms used in the effect
  13142. */
  13143. static PrepareUniforms(uniformsList: string[]): void;
  13144. /**
  13145. * Returns color grading data based on a hue, density, saturation and exposure value.
  13146. * @param filterHue The hue of the color filter.
  13147. * @param filterDensity The density of the color filter.
  13148. * @param saturation The saturation.
  13149. * @param exposure The exposure.
  13150. * @param result The result data container.
  13151. */
  13152. private getColorGradingDataToRef;
  13153. /**
  13154. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  13155. * @param value The input slider value in range [-100,100].
  13156. * @returns Adjusted value.
  13157. */
  13158. private static applyColorGradingSliderNonlinear;
  13159. /**
  13160. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  13161. * @param hue The hue (H) input.
  13162. * @param saturation The saturation (S) input.
  13163. * @param brightness The brightness (B) input.
  13164. * @result An RGBA color represented as Vector4.
  13165. */
  13166. private static fromHSBToRef;
  13167. /**
  13168. * Returns a value clamped between min and max
  13169. * @param value The value to clamp
  13170. * @param min The minimum of value
  13171. * @param max The maximum of value
  13172. * @returns The clamped value.
  13173. */
  13174. private static clamp;
  13175. /**
  13176. * Clones the current color curve instance.
  13177. * @return The cloned curves
  13178. */
  13179. clone(): ColorCurves;
  13180. /**
  13181. * Serializes the current color curve instance to a json representation.
  13182. * @return a JSON representation
  13183. */
  13184. serialize(): any;
  13185. /**
  13186. * Parses the color curve from a json representation.
  13187. * @param source the JSON source to parse
  13188. * @return The parsed curves
  13189. */
  13190. static Parse(source: any): ColorCurves;
  13191. }
  13192. }
  13193. declare module BABYLON {
  13194. /**
  13195. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13196. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13197. */
  13198. class EffectFallbacks {
  13199. private _defines;
  13200. private _currentRank;
  13201. private _maxRank;
  13202. private _mesh;
  13203. /**
  13204. * Removes the fallback from the bound mesh.
  13205. */
  13206. unBindMesh(): void;
  13207. /**
  13208. * Adds a fallback on the specified property.
  13209. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13210. * @param define The name of the define in the shader
  13211. */
  13212. addFallback(rank: number, define: string): void;
  13213. /**
  13214. * Sets the mesh to use CPU skinning when needing to fallback.
  13215. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13216. * @param mesh The mesh to use the fallbacks.
  13217. */
  13218. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13219. /**
  13220. * Checks to see if more fallbacks are still availible.
  13221. */
  13222. readonly isMoreFallbacks: boolean;
  13223. /**
  13224. * Removes the defines that shoould be removed when falling back.
  13225. * @param currentDefines defines the current define statements for the shader.
  13226. * @param effect defines the current effect we try to compile
  13227. * @returns The resulting defines with defines of the current rank removed.
  13228. */
  13229. reduce(currentDefines: string, effect: Effect): string;
  13230. }
  13231. /**
  13232. * Options to be used when creating an effect.
  13233. */
  13234. class EffectCreationOptions {
  13235. /**
  13236. * Atrributes that will be used in the shader.
  13237. */
  13238. attributes: string[];
  13239. /**
  13240. * Uniform varible names that will be set in the shader.
  13241. */
  13242. uniformsNames: string[];
  13243. /**
  13244. * Uniform buffer varible names that will be set in the shader.
  13245. */
  13246. uniformBuffersNames: string[];
  13247. /**
  13248. * Sampler texture variable names that will be set in the shader.
  13249. */
  13250. samplers: string[];
  13251. /**
  13252. * Define statements that will be set in the shader.
  13253. */
  13254. defines: any;
  13255. /**
  13256. * Possible fallbacks for this effect to improve performance when needed.
  13257. */
  13258. fallbacks: Nullable<EffectFallbacks>;
  13259. /**
  13260. * Callback that will be called when the shader is compiled.
  13261. */
  13262. onCompiled: Nullable<(effect: Effect) => void>;
  13263. /**
  13264. * Callback that will be called if an error occurs during shader compilation.
  13265. */
  13266. onError: Nullable<(effect: Effect, errors: string) => void>;
  13267. /**
  13268. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13269. */
  13270. indexParameters: any;
  13271. /**
  13272. * Max number of lights that can be used in the shader.
  13273. */
  13274. maxSimultaneousLights: number;
  13275. /**
  13276. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13277. */
  13278. transformFeedbackVaryings: Nullable<string[]>;
  13279. }
  13280. /**
  13281. * Effect containing vertex and fragment shader that can be executed on an object.
  13282. */
  13283. class Effect {
  13284. /**
  13285. * Name of the effect.
  13286. */
  13287. name: any;
  13288. /**
  13289. * String container all the define statements that should be set on the shader.
  13290. */
  13291. defines: string;
  13292. /**
  13293. * Callback that will be called when the shader is compiled.
  13294. */
  13295. onCompiled: Nullable<(effect: Effect) => void>;
  13296. /**
  13297. * Callback that will be called if an error occurs during shader compilation.
  13298. */
  13299. onError: Nullable<(effect: Effect, errors: string) => void>;
  13300. /**
  13301. * Callback that will be called when effect is bound.
  13302. */
  13303. onBind: Nullable<(effect: Effect) => void>;
  13304. /**
  13305. * Unique ID of the effect.
  13306. */
  13307. uniqueId: number;
  13308. /**
  13309. * Observable that will be called when the shader is compiled.
  13310. */
  13311. onCompileObservable: Observable<Effect>;
  13312. /**
  13313. * Observable that will be called if an error occurs during shader compilation.
  13314. */
  13315. onErrorObservable: Observable<Effect>;
  13316. /** @hidden */
  13317. _onBindObservable: Nullable<Observable<Effect>>;
  13318. /**
  13319. * Observable that will be called when effect is bound.
  13320. */
  13321. readonly onBindObservable: Observable<Effect>;
  13322. /** @hidden */
  13323. _bonesComputationForcedToCPU: boolean;
  13324. private static _uniqueIdSeed;
  13325. private _engine;
  13326. private _uniformBuffersNames;
  13327. private _uniformsNames;
  13328. private _samplers;
  13329. private _isReady;
  13330. private _compilationError;
  13331. private _attributesNames;
  13332. private _attributes;
  13333. private _uniforms;
  13334. /**
  13335. * Key for the effect.
  13336. */
  13337. _key: string;
  13338. private _indexParameters;
  13339. private _fallbacks;
  13340. private _vertexSourceCode;
  13341. private _fragmentSourceCode;
  13342. private _vertexSourceCodeOverride;
  13343. private _fragmentSourceCodeOverride;
  13344. private _transformFeedbackVaryings;
  13345. /**
  13346. * Compiled shader to webGL program.
  13347. */
  13348. _program: WebGLProgram;
  13349. private _valueCache;
  13350. private static _baseCache;
  13351. /**
  13352. * Instantiates an effect.
  13353. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13354. * @param baseName Name of the effect.
  13355. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13356. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13357. * @param samplers List of sampler variables that will be passed to the shader.
  13358. * @param engine Engine to be used to render the effect
  13359. * @param defines Define statements to be added to the shader.
  13360. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13361. * @param onCompiled Callback that will be called when the shader is compiled.
  13362. * @param onError Callback that will be called if an error occurs during shader compilation.
  13363. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13364. */
  13365. 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);
  13366. /**
  13367. * Unique key for this effect
  13368. */
  13369. readonly key: string;
  13370. /**
  13371. * If the effect has been compiled and prepared.
  13372. * @returns if the effect is compiled and prepared.
  13373. */
  13374. isReady(): boolean;
  13375. /**
  13376. * The engine the effect was initialized with.
  13377. * @returns the engine.
  13378. */
  13379. getEngine(): Engine;
  13380. /**
  13381. * The compiled webGL program for the effect
  13382. * @returns the webGL program.
  13383. */
  13384. getProgram(): WebGLProgram;
  13385. /**
  13386. * The set of names of attribute variables for the shader.
  13387. * @returns An array of attribute names.
  13388. */
  13389. getAttributesNames(): string[];
  13390. /**
  13391. * Returns the attribute at the given index.
  13392. * @param index The index of the attribute.
  13393. * @returns The location of the attribute.
  13394. */
  13395. getAttributeLocation(index: number): number;
  13396. /**
  13397. * Returns the attribute based on the name of the variable.
  13398. * @param name of the attribute to look up.
  13399. * @returns the attribute location.
  13400. */
  13401. getAttributeLocationByName(name: string): number;
  13402. /**
  13403. * The number of attributes.
  13404. * @returns the numnber of attributes.
  13405. */
  13406. getAttributesCount(): number;
  13407. /**
  13408. * Gets the index of a uniform variable.
  13409. * @param uniformName of the uniform to look up.
  13410. * @returns the index.
  13411. */
  13412. getUniformIndex(uniformName: string): number;
  13413. /**
  13414. * Returns the attribute based on the name of the variable.
  13415. * @param uniformName of the uniform to look up.
  13416. * @returns the location of the uniform.
  13417. */
  13418. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13419. /**
  13420. * Returns an array of sampler variable names
  13421. * @returns The array of sampler variable neames.
  13422. */
  13423. getSamplers(): string[];
  13424. /**
  13425. * The error from the last compilation.
  13426. * @returns the error string.
  13427. */
  13428. getCompilationError(): string;
  13429. /**
  13430. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13431. * @param func The callback to be used.
  13432. */
  13433. executeWhenCompiled(func: (effect: Effect) => void): void;
  13434. /** @hidden */
  13435. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13436. /** @hidden */
  13437. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13438. /** @hidden */
  13439. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13440. private _processShaderConversion;
  13441. private _processIncludes;
  13442. private _processPrecision;
  13443. /**
  13444. * Recompiles the webGL program
  13445. * @param vertexSourceCode The source code for the vertex shader.
  13446. * @param fragmentSourceCode The source code for the fragment shader.
  13447. * @param onCompiled Callback called when completed.
  13448. * @param onError Callback called on error.
  13449. */
  13450. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13451. /**
  13452. * Gets the uniform locations of the the specified variable names
  13453. * @param names THe names of the variables to lookup.
  13454. * @returns Array of locations in the same order as variable names.
  13455. */
  13456. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13457. /**
  13458. * Prepares the effect
  13459. */
  13460. _prepareEffect(): void;
  13461. /**
  13462. * Checks if the effect is supported. (Must be called after compilation)
  13463. */
  13464. readonly isSupported: boolean;
  13465. /**
  13466. * Binds a texture to the engine to be used as output of the shader.
  13467. * @param channel Name of the output variable.
  13468. * @param texture Texture to bind.
  13469. */
  13470. _bindTexture(channel: string, texture: InternalTexture): void;
  13471. /**
  13472. * Sets a texture on the engine to be used in the shader.
  13473. * @param channel Name of the sampler variable.
  13474. * @param texture Texture to set.
  13475. */
  13476. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13477. /**
  13478. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13479. * @param channel Name of the sampler variable.
  13480. * @param texture Texture to set.
  13481. */
  13482. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13483. /**
  13484. * Sets an array of textures on the engine to be used in the shader.
  13485. * @param channel Name of the variable.
  13486. * @param textures Textures to set.
  13487. */
  13488. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13489. /**
  13490. * 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)
  13491. * @param channel Name of the sampler variable.
  13492. * @param postProcess Post process to get the input texture from.
  13493. */
  13494. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13495. /**
  13496. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13497. * 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)
  13498. * @param channel Name of the sampler variable.
  13499. * @param postProcess Post process to get the output texture from.
  13500. */
  13501. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13502. /** @hidden */
  13503. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13504. /** @hidden */
  13505. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13506. /** @hidden */
  13507. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13508. /** @hidden */
  13509. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13510. /**
  13511. * Binds a buffer to a uniform.
  13512. * @param buffer Buffer to bind.
  13513. * @param name Name of the uniform variable to bind to.
  13514. */
  13515. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13516. /**
  13517. * Binds block to a uniform.
  13518. * @param blockName Name of the block to bind.
  13519. * @param index Index to bind.
  13520. */
  13521. bindUniformBlock(blockName: string, index: number): void;
  13522. /**
  13523. * Sets an interger value on a uniform variable.
  13524. * @param uniformName Name of the variable.
  13525. * @param value Value to be set.
  13526. * @returns this effect.
  13527. */
  13528. setInt(uniformName: string, value: number): Effect;
  13529. /**
  13530. * Sets an int array on a uniform variable.
  13531. * @param uniformName Name of the variable.
  13532. * @param array array to be set.
  13533. * @returns this effect.
  13534. */
  13535. setIntArray(uniformName: string, array: Int32Array): Effect;
  13536. /**
  13537. * 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)
  13538. * @param uniformName Name of the variable.
  13539. * @param array array to be set.
  13540. * @returns this effect.
  13541. */
  13542. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13543. /**
  13544. * 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)
  13545. * @param uniformName Name of the variable.
  13546. * @param array array to be set.
  13547. * @returns this effect.
  13548. */
  13549. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13550. /**
  13551. * 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)
  13552. * @param uniformName Name of the variable.
  13553. * @param array array to be set.
  13554. * @returns this effect.
  13555. */
  13556. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13557. /**
  13558. * Sets an float array on a uniform variable.
  13559. * @param uniformName Name of the variable.
  13560. * @param array array to be set.
  13561. * @returns this effect.
  13562. */
  13563. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13564. /**
  13565. * 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)
  13566. * @param uniformName Name of the variable.
  13567. * @param array array to be set.
  13568. * @returns this effect.
  13569. */
  13570. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13571. /**
  13572. * 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)
  13573. * @param uniformName Name of the variable.
  13574. * @param array array to be set.
  13575. * @returns this effect.
  13576. */
  13577. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13578. /**
  13579. * 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)
  13580. * @param uniformName Name of the variable.
  13581. * @param array array to be set.
  13582. * @returns this effect.
  13583. */
  13584. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13585. /**
  13586. * Sets an array on a uniform variable.
  13587. * @param uniformName Name of the variable.
  13588. * @param array array to be set.
  13589. * @returns this effect.
  13590. */
  13591. setArray(uniformName: string, array: number[]): Effect;
  13592. /**
  13593. * 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)
  13594. * @param uniformName Name of the variable.
  13595. * @param array array to be set.
  13596. * @returns this effect.
  13597. */
  13598. setArray2(uniformName: string, array: number[]): Effect;
  13599. /**
  13600. * 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)
  13601. * @param uniformName Name of the variable.
  13602. * @param array array to be set.
  13603. * @returns this effect.
  13604. */
  13605. setArray3(uniformName: string, array: number[]): Effect;
  13606. /**
  13607. * 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)
  13608. * @param uniformName Name of the variable.
  13609. * @param array array to be set.
  13610. * @returns this effect.
  13611. */
  13612. setArray4(uniformName: string, array: number[]): Effect;
  13613. /**
  13614. * Sets matrices on a uniform variable.
  13615. * @param uniformName Name of the variable.
  13616. * @param matrices matrices to be set.
  13617. * @returns this effect.
  13618. */
  13619. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13620. /**
  13621. * Sets matrix on a uniform variable.
  13622. * @param uniformName Name of the variable.
  13623. * @param matrix matrix to be set.
  13624. * @returns this effect.
  13625. */
  13626. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13627. /**
  13628. * 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)
  13629. * @param uniformName Name of the variable.
  13630. * @param matrix matrix to be set.
  13631. * @returns this effect.
  13632. */
  13633. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13634. /**
  13635. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13636. * @param uniformName Name of the variable.
  13637. * @param matrix matrix to be set.
  13638. * @returns this effect.
  13639. */
  13640. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13641. /**
  13642. * Sets a float on a uniform variable.
  13643. * @param uniformName Name of the variable.
  13644. * @param value value to be set.
  13645. * @returns this effect.
  13646. */
  13647. setFloat(uniformName: string, value: number): Effect;
  13648. /**
  13649. * Sets a boolean on a uniform variable.
  13650. * @param uniformName Name of the variable.
  13651. * @param bool value to be set.
  13652. * @returns this effect.
  13653. */
  13654. setBool(uniformName: string, bool: boolean): Effect;
  13655. /**
  13656. * Sets a Vector2 on a uniform variable.
  13657. * @param uniformName Name of the variable.
  13658. * @param vector2 vector2 to be set.
  13659. * @returns this effect.
  13660. */
  13661. setVector2(uniformName: string, vector2: Vector2): Effect;
  13662. /**
  13663. * Sets a float2 on a uniform variable.
  13664. * @param uniformName Name of the variable.
  13665. * @param x First float in float2.
  13666. * @param y Second float in float2.
  13667. * @returns this effect.
  13668. */
  13669. setFloat2(uniformName: string, x: number, y: number): Effect;
  13670. /**
  13671. * Sets a Vector3 on a uniform variable.
  13672. * @param uniformName Name of the variable.
  13673. * @param vector3 Value to be set.
  13674. * @returns this effect.
  13675. */
  13676. setVector3(uniformName: string, vector3: Vector3): Effect;
  13677. /**
  13678. * Sets a float3 on a uniform variable.
  13679. * @param uniformName Name of the variable.
  13680. * @param x First float in float3.
  13681. * @param y Second float in float3.
  13682. * @param z Third float in float3.
  13683. * @returns this effect.
  13684. */
  13685. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13686. /**
  13687. * Sets a Vector4 on a uniform variable.
  13688. * @param uniformName Name of the variable.
  13689. * @param vector4 Value to be set.
  13690. * @returns this effect.
  13691. */
  13692. setVector4(uniformName: string, vector4: Vector4): Effect;
  13693. /**
  13694. * Sets a float4 on a uniform variable.
  13695. * @param uniformName Name of the variable.
  13696. * @param x First float in float4.
  13697. * @param y Second float in float4.
  13698. * @param z Third float in float4.
  13699. * @param w Fourth float in float4.
  13700. * @returns this effect.
  13701. */
  13702. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13703. /**
  13704. * Sets a Color3 on a uniform variable.
  13705. * @param uniformName Name of the variable.
  13706. * @param color3 Value to be set.
  13707. * @returns this effect.
  13708. */
  13709. setColor3(uniformName: string, color3: Color3): Effect;
  13710. /**
  13711. * Sets a Color4 on a uniform variable.
  13712. * @param uniformName Name of the variable.
  13713. * @param color3 Value to be set.
  13714. * @param alpha Alpha value to be set.
  13715. * @returns this effect.
  13716. */
  13717. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13718. /**
  13719. * Sets a Color4 on a uniform variable
  13720. * @param uniformName defines the name of the variable
  13721. * @param color4 defines the value to be set
  13722. * @returns this effect.
  13723. */
  13724. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13725. /**
  13726. * This function will add a new shader to the shader store
  13727. * @param name the name of the shader
  13728. * @param pixelShader optional pixel shader content
  13729. * @param vertexShader optional vertex shader content
  13730. */
  13731. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  13732. /**
  13733. * Store of each shader (The can be looked up using effect.key)
  13734. */
  13735. static ShadersStore: {
  13736. [key: string]: string;
  13737. };
  13738. /**
  13739. * Store of each included file for a shader (The can be looked up using effect.key)
  13740. */
  13741. static IncludesShadersStore: {
  13742. [key: string]: string;
  13743. };
  13744. /**
  13745. * Resets the cache of effects.
  13746. */
  13747. static ResetCache(): void;
  13748. }
  13749. }
  13750. declare module BABYLON {
  13751. class FresnelParameters {
  13752. private _isEnabled;
  13753. isEnabled: boolean;
  13754. leftColor: Color3;
  13755. rightColor: Color3;
  13756. bias: number;
  13757. power: number;
  13758. clone(): FresnelParameters;
  13759. serialize(): any;
  13760. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13761. }
  13762. }
  13763. declare module BABYLON {
  13764. /**
  13765. * Interface to follow in your material defines to integrate easily the
  13766. * Image proccessing functions.
  13767. * @hidden
  13768. */
  13769. interface IImageProcessingConfigurationDefines {
  13770. IMAGEPROCESSING: boolean;
  13771. VIGNETTE: boolean;
  13772. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13773. VIGNETTEBLENDMODEOPAQUE: boolean;
  13774. TONEMAPPING: boolean;
  13775. TONEMAPPING_ACES: boolean;
  13776. CONTRAST: boolean;
  13777. EXPOSURE: boolean;
  13778. COLORCURVES: boolean;
  13779. COLORGRADING: boolean;
  13780. COLORGRADING3D: boolean;
  13781. SAMPLER3DGREENDEPTH: boolean;
  13782. SAMPLER3DBGRMAP: boolean;
  13783. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13784. }
  13785. /**
  13786. * @hidden
  13787. */
  13788. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13789. IMAGEPROCESSING: boolean;
  13790. VIGNETTE: boolean;
  13791. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13792. VIGNETTEBLENDMODEOPAQUE: boolean;
  13793. TONEMAPPING: boolean;
  13794. TONEMAPPING_ACES: boolean;
  13795. CONTRAST: boolean;
  13796. COLORCURVES: boolean;
  13797. COLORGRADING: boolean;
  13798. COLORGRADING3D: boolean;
  13799. SAMPLER3DGREENDEPTH: boolean;
  13800. SAMPLER3DBGRMAP: boolean;
  13801. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13802. EXPOSURE: boolean;
  13803. constructor();
  13804. }
  13805. /**
  13806. * This groups together the common properties used for image processing either in direct forward pass
  13807. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13808. * or not.
  13809. */
  13810. class ImageProcessingConfiguration {
  13811. /**
  13812. * Default tone mapping applied in BabylonJS.
  13813. */
  13814. static readonly TONEMAPPING_STANDARD: number;
  13815. /**
  13816. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  13817. * to other engines rendering to increase portability.
  13818. */
  13819. static readonly TONEMAPPING_ACES: number;
  13820. /**
  13821. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13822. */
  13823. colorCurves: Nullable<ColorCurves>;
  13824. private _colorCurvesEnabled;
  13825. /**
  13826. * Gets wether the color curves effect is enabled.
  13827. */
  13828. /**
  13829. * Sets wether the color curves effect is enabled.
  13830. */
  13831. colorCurvesEnabled: boolean;
  13832. /**
  13833. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13834. */
  13835. colorGradingTexture: Nullable<BaseTexture>;
  13836. private _colorGradingEnabled;
  13837. /**
  13838. * Gets wether the color grading effect is enabled.
  13839. */
  13840. /**
  13841. * Sets wether the color grading effect is enabled.
  13842. */
  13843. colorGradingEnabled: boolean;
  13844. private _colorGradingWithGreenDepth;
  13845. /**
  13846. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13847. */
  13848. /**
  13849. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13850. */
  13851. colorGradingWithGreenDepth: boolean;
  13852. private _colorGradingBGR;
  13853. /**
  13854. * Gets wether the color grading texture contains BGR values.
  13855. */
  13856. /**
  13857. * Sets wether the color grading texture contains BGR values.
  13858. */
  13859. colorGradingBGR: boolean;
  13860. _exposure: number;
  13861. /**
  13862. * Gets the Exposure used in the effect.
  13863. */
  13864. /**
  13865. * Sets the Exposure used in the effect.
  13866. */
  13867. exposure: number;
  13868. private _toneMappingEnabled;
  13869. /**
  13870. * Gets wether the tone mapping effect is enabled.
  13871. */
  13872. /**
  13873. * Sets wether the tone mapping effect is enabled.
  13874. */
  13875. toneMappingEnabled: boolean;
  13876. private _toneMappingType;
  13877. /**
  13878. * Gets the type of tone mapping effect.
  13879. */
  13880. /**
  13881. * Sets the type of tone mapping effect used in BabylonJS.
  13882. */
  13883. toneMappingType: number;
  13884. protected _contrast: number;
  13885. /**
  13886. * Gets the contrast used in the effect.
  13887. */
  13888. /**
  13889. * Sets the contrast used in the effect.
  13890. */
  13891. contrast: number;
  13892. /**
  13893. * Vignette stretch size.
  13894. */
  13895. vignetteStretch: number;
  13896. /**
  13897. * Vignette centre X Offset.
  13898. */
  13899. vignetteCentreX: number;
  13900. /**
  13901. * Vignette centre Y Offset.
  13902. */
  13903. vignetteCentreY: number;
  13904. /**
  13905. * Vignette weight or intensity of the vignette effect.
  13906. */
  13907. vignetteWeight: number;
  13908. /**
  13909. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13910. * if vignetteEnabled is set to true.
  13911. */
  13912. vignetteColor: Color4;
  13913. /**
  13914. * Camera field of view used by the Vignette effect.
  13915. */
  13916. vignetteCameraFov: number;
  13917. private _vignetteBlendMode;
  13918. /**
  13919. * Gets the vignette blend mode allowing different kind of effect.
  13920. */
  13921. /**
  13922. * Sets the vignette blend mode allowing different kind of effect.
  13923. */
  13924. vignetteBlendMode: number;
  13925. private _vignetteEnabled;
  13926. /**
  13927. * Gets wether the vignette effect is enabled.
  13928. */
  13929. /**
  13930. * Sets wether the vignette effect is enabled.
  13931. */
  13932. vignetteEnabled: boolean;
  13933. private _applyByPostProcess;
  13934. /**
  13935. * Gets wether the image processing is applied through a post process or not.
  13936. */
  13937. /**
  13938. * Sets wether the image processing is applied through a post process or not.
  13939. */
  13940. applyByPostProcess: boolean;
  13941. private _isEnabled;
  13942. /**
  13943. * Gets wether the image processing is enabled or not.
  13944. */
  13945. /**
  13946. * Sets wether the image processing is enabled or not.
  13947. */
  13948. isEnabled: boolean;
  13949. /**
  13950. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13951. */
  13952. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13953. /**
  13954. * Method called each time the image processing information changes requires to recompile the effect.
  13955. */
  13956. protected _updateParameters(): void;
  13957. getClassName(): string;
  13958. /**
  13959. * Prepare the list of uniforms associated with the Image Processing effects.
  13960. * @param uniformsList The list of uniforms used in the effect
  13961. * @param defines the list of defines currently in use
  13962. */
  13963. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13964. /**
  13965. * Prepare the list of samplers associated with the Image Processing effects.
  13966. * @param uniformsList The list of uniforms used in the effect
  13967. * @param defines the list of defines currently in use
  13968. */
  13969. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13970. /**
  13971. * Prepare the list of defines associated to the shader.
  13972. * @param defines the list of defines to complete
  13973. */
  13974. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13975. /**
  13976. * Returns true if all the image processing information are ready.
  13977. */
  13978. isReady(): boolean;
  13979. /**
  13980. * Binds the image processing to the shader.
  13981. * @param effect The effect to bind to
  13982. */
  13983. bind(effect: Effect, aspectRatio?: number): void;
  13984. /**
  13985. * Clones the current image processing instance.
  13986. * @return The cloned image processing
  13987. */
  13988. clone(): ImageProcessingConfiguration;
  13989. /**
  13990. * Serializes the current image processing instance to a json representation.
  13991. * @return a JSON representation
  13992. */
  13993. serialize(): any;
  13994. /**
  13995. * Parses the image processing from a json representation.
  13996. * @param source the JSON source to parse
  13997. * @return The parsed image processing
  13998. */
  13999. static Parse(source: any): ImageProcessingConfiguration;
  14000. private static _VIGNETTEMODE_MULTIPLY;
  14001. private static _VIGNETTEMODE_OPAQUE;
  14002. /**
  14003. * Used to apply the vignette as a mix with the pixel color.
  14004. */
  14005. static readonly VIGNETTEMODE_MULTIPLY: number;
  14006. /**
  14007. * Used to apply the vignette as a replacement of the pixel color.
  14008. */
  14009. static readonly VIGNETTEMODE_OPAQUE: number;
  14010. }
  14011. }
  14012. declare module BABYLON {
  14013. /**
  14014. * Manages the defines for the Material
  14015. */
  14016. class MaterialDefines {
  14017. private _keys;
  14018. private _isDirty;
  14019. /** @hidden */
  14020. _renderId: number;
  14021. /** @hidden */
  14022. _areLightsDirty: boolean;
  14023. /** @hidden */
  14024. _areAttributesDirty: boolean;
  14025. /** @hidden */
  14026. _areTexturesDirty: boolean;
  14027. /** @hidden */
  14028. _areFresnelDirty: boolean;
  14029. /** @hidden */
  14030. _areMiscDirty: boolean;
  14031. /** @hidden */
  14032. _areImageProcessingDirty: boolean;
  14033. /** @hidden */
  14034. _normals: boolean;
  14035. /** @hidden */
  14036. _uvs: boolean;
  14037. /** @hidden */
  14038. _needNormals: boolean;
  14039. /** @hidden */
  14040. _needUVs: boolean;
  14041. /**
  14042. * Specifies if the material needs to be re-calculated
  14043. */
  14044. readonly isDirty: boolean;
  14045. /**
  14046. * Marks the material to indicate that it has been re-calculated
  14047. */
  14048. markAsProcessed(): void;
  14049. /**
  14050. * Marks the material to indicate that it needs to be re-calculated
  14051. */
  14052. markAsUnprocessed(): void;
  14053. /**
  14054. * Marks the material to indicate all of its defines need to be re-calculated
  14055. */
  14056. markAllAsDirty(): void;
  14057. /**
  14058. * Marks the material to indicate that image processing needs to be re-calculated
  14059. */
  14060. markAsImageProcessingDirty(): void;
  14061. /**
  14062. * Marks the material to indicate the lights need to be re-calculated
  14063. */
  14064. markAsLightDirty(): void;
  14065. /**
  14066. * Marks the attribute state as changed
  14067. */
  14068. markAsAttributesDirty(): void;
  14069. /**
  14070. * Marks the texture state as changed
  14071. */
  14072. markAsTexturesDirty(): void;
  14073. /**
  14074. * Marks the fresnel state as changed
  14075. */
  14076. markAsFresnelDirty(): void;
  14077. /**
  14078. * Marks the misc state as changed
  14079. */
  14080. markAsMiscDirty(): void;
  14081. /**
  14082. * Rebuilds the material defines
  14083. */
  14084. rebuild(): void;
  14085. /**
  14086. * Specifies if two material defines are equal
  14087. * @param other - A material define instance to compare to
  14088. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  14089. */
  14090. isEqual(other: MaterialDefines): boolean;
  14091. /**
  14092. * Clones this instance's defines to another instance
  14093. * @param other - material defines to clone values to
  14094. */
  14095. cloneTo(other: MaterialDefines): void;
  14096. /**
  14097. * Resets the material define values
  14098. */
  14099. reset(): void;
  14100. /**
  14101. * Converts the material define values to a string
  14102. * @returns - String of material define information
  14103. */
  14104. toString(): string;
  14105. }
  14106. /**
  14107. * Base class for the main features of a material in Babylon.js
  14108. */
  14109. class Material implements IAnimatable {
  14110. private static _TriangleFillMode;
  14111. private static _WireFrameFillMode;
  14112. private static _PointFillMode;
  14113. private static _PointListDrawMode;
  14114. private static _LineListDrawMode;
  14115. private static _LineLoopDrawMode;
  14116. private static _LineStripDrawMode;
  14117. private static _TriangleStripDrawMode;
  14118. private static _TriangleFanDrawMode;
  14119. /**
  14120. * Returns the triangle fill mode
  14121. */
  14122. static readonly TriangleFillMode: number;
  14123. /**
  14124. * Returns the wireframe mode
  14125. */
  14126. static readonly WireFrameFillMode: number;
  14127. /**
  14128. * Returns the point fill mode
  14129. */
  14130. static readonly PointFillMode: number;
  14131. /**
  14132. * Returns the point list draw mode
  14133. */
  14134. static readonly PointListDrawMode: number;
  14135. /**
  14136. * Returns the line list draw mode
  14137. */
  14138. static readonly LineListDrawMode: number;
  14139. /**
  14140. * Returns the line loop draw mode
  14141. */
  14142. static readonly LineLoopDrawMode: number;
  14143. /**
  14144. * Returns the line strip draw mode
  14145. */
  14146. static readonly LineStripDrawMode: number;
  14147. /**
  14148. * Returns the triangle strip draw mode
  14149. */
  14150. static readonly TriangleStripDrawMode: number;
  14151. /**
  14152. * Returns the triangle fan draw mode
  14153. */
  14154. static readonly TriangleFanDrawMode: number;
  14155. /**
  14156. * Stores the clock-wise side orientation
  14157. */
  14158. private static _ClockWiseSideOrientation;
  14159. /**
  14160. * Stores the counter clock-wise side orientation
  14161. */
  14162. private static _CounterClockWiseSideOrientation;
  14163. /**
  14164. * Returns the clock-wise side orientation
  14165. */
  14166. static readonly ClockWiseSideOrientation: number;
  14167. /**
  14168. * Returns the counter clock-wise side orientation
  14169. */
  14170. static readonly CounterClockWiseSideOrientation: number;
  14171. /**
  14172. * The dirty texture flag value
  14173. */
  14174. private static _TextureDirtyFlag;
  14175. /**
  14176. * The dirty light flag value
  14177. */
  14178. private static _LightDirtyFlag;
  14179. /**
  14180. * The dirty fresnel flag value
  14181. */
  14182. private static _FresnelDirtyFlag;
  14183. /**
  14184. * The dirty attribute flag value
  14185. */
  14186. private static _AttributesDirtyFlag;
  14187. /**
  14188. * The dirty misc flag value
  14189. */
  14190. private static _MiscDirtyFlag;
  14191. /**
  14192. * Returns the dirty texture flag value
  14193. */
  14194. static readonly TextureDirtyFlag: number;
  14195. /**
  14196. * Returns the dirty light flag value
  14197. */
  14198. static readonly LightDirtyFlag: number;
  14199. /**
  14200. * Returns the dirty fresnel flag value
  14201. */
  14202. static readonly FresnelDirtyFlag: number;
  14203. /**
  14204. * Returns the dirty attributes flag value
  14205. */
  14206. static readonly AttributesDirtyFlag: number;
  14207. /**
  14208. * Returns the dirty misc flag value
  14209. */
  14210. static readonly MiscDirtyFlag: number;
  14211. /**
  14212. * The ID of the material
  14213. */
  14214. id: string;
  14215. /**
  14216. * Gets or sets the unique id of the material
  14217. */
  14218. uniqueId: number;
  14219. /**
  14220. * The name of the material
  14221. */
  14222. name: string;
  14223. /**
  14224. * Specifies if the ready state should be checked on each call
  14225. */
  14226. checkReadyOnEveryCall: boolean;
  14227. /**
  14228. * Specifies if the ready state should be checked once
  14229. */
  14230. checkReadyOnlyOnce: boolean;
  14231. /**
  14232. * The state of the material
  14233. */
  14234. state: string;
  14235. /**
  14236. * The alpha value of the material
  14237. */
  14238. protected _alpha: number;
  14239. /**
  14240. * Sets the alpha value of the material
  14241. */
  14242. /**
  14243. * Gets the alpha value of the material
  14244. */
  14245. alpha: number;
  14246. /**
  14247. * Specifies if back face culling is enabled
  14248. */
  14249. protected _backFaceCulling: boolean;
  14250. /**
  14251. * Sets the back-face culling state
  14252. */
  14253. /**
  14254. * Gets the back-face culling state
  14255. */
  14256. backFaceCulling: boolean;
  14257. /**
  14258. * Stores the value for side orientation
  14259. */
  14260. sideOrientation: number;
  14261. /**
  14262. * Callback triggered when the material is compiled
  14263. */
  14264. onCompiled: (effect: Effect) => void;
  14265. /**
  14266. * Callback triggered when an error occurs
  14267. */
  14268. onError: (effect: Effect, errors: string) => void;
  14269. /**
  14270. * Callback triggered to get the render target textures
  14271. */
  14272. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14273. /**
  14274. * Specifies if the material should be serialized
  14275. */
  14276. doNotSerialize: boolean;
  14277. /**
  14278. * Specifies if the effect should be stored on sub meshes
  14279. */
  14280. storeEffectOnSubMeshes: boolean;
  14281. /**
  14282. * Stores the animations for the material
  14283. */
  14284. animations: Array<Animation>;
  14285. /**
  14286. * An event triggered when the material is disposed
  14287. */
  14288. onDisposeObservable: Observable<Material>;
  14289. /**
  14290. * An observer which watches for dispose events
  14291. */
  14292. private _onDisposeObserver;
  14293. private _onUnBindObservable;
  14294. /**
  14295. * Called during a dispose event
  14296. */
  14297. onDispose: () => void;
  14298. private _onBindObservable;
  14299. /**
  14300. * An event triggered when the material is bound
  14301. */
  14302. readonly onBindObservable: Observable<AbstractMesh>;
  14303. /**
  14304. * An observer which watches for bind events
  14305. */
  14306. private _onBindObserver;
  14307. /**
  14308. * Called during a bind event
  14309. */
  14310. onBind: (Mesh: AbstractMesh) => void;
  14311. /**
  14312. * An event triggered when the material is unbound
  14313. */
  14314. readonly onUnBindObservable: Observable<Material>;
  14315. /**
  14316. * Stores the value of the alpha mode
  14317. */
  14318. private _alphaMode;
  14319. /**
  14320. * Sets the value of the alpha mode.
  14321. *
  14322. * | Value | Type | Description |
  14323. * | --- | --- | --- |
  14324. * | 0 | ALPHA_DISABLE | |
  14325. * | 1 | ALPHA_ADD | |
  14326. * | 2 | ALPHA_COMBINE | |
  14327. * | 3 | ALPHA_SUBTRACT | |
  14328. * | 4 | ALPHA_MULTIPLY | |
  14329. * | 5 | ALPHA_MAXIMIZED | |
  14330. * | 6 | ALPHA_ONEONE | |
  14331. * | 7 | ALPHA_PREMULTIPLIED | |
  14332. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14333. * | 9 | ALPHA_INTERPOLATE | |
  14334. * | 10 | ALPHA_SCREENMODE | |
  14335. *
  14336. */
  14337. /**
  14338. * Gets the value of the alpha mode
  14339. */
  14340. alphaMode: number;
  14341. /**
  14342. * Stores the state of the need depth pre-pass value
  14343. */
  14344. private _needDepthPrePass;
  14345. /**
  14346. * Sets the need depth pre-pass value
  14347. */
  14348. /**
  14349. * Gets the depth pre-pass value
  14350. */
  14351. needDepthPrePass: boolean;
  14352. /**
  14353. * Specifies if depth writing should be disabled
  14354. */
  14355. disableDepthWrite: boolean;
  14356. /**
  14357. * Specifies if depth writing should be forced
  14358. */
  14359. forceDepthWrite: boolean;
  14360. /**
  14361. * Specifies if there should be a separate pass for culling
  14362. */
  14363. separateCullingPass: boolean;
  14364. /**
  14365. * Stores the state specifing if fog should be enabled
  14366. */
  14367. private _fogEnabled;
  14368. /**
  14369. * Sets the state for enabling fog
  14370. */
  14371. /**
  14372. * Gets the value of the fog enabled state
  14373. */
  14374. fogEnabled: boolean;
  14375. /**
  14376. * Stores the size of points
  14377. */
  14378. pointSize: number;
  14379. /**
  14380. * Stores the z offset value
  14381. */
  14382. zOffset: number;
  14383. /**
  14384. * Gets a value specifying if wireframe mode is enabled
  14385. */
  14386. /**
  14387. * Sets the state of wireframe mode
  14388. */
  14389. wireframe: boolean;
  14390. /**
  14391. * Gets the value specifying if point clouds are enabled
  14392. */
  14393. /**
  14394. * Sets the state of point cloud mode
  14395. */
  14396. pointsCloud: boolean;
  14397. /**
  14398. * Gets the material fill mode
  14399. */
  14400. /**
  14401. * Sets the material fill mode
  14402. */
  14403. fillMode: number;
  14404. /**
  14405. * Stores the effects for the material
  14406. */
  14407. _effect: Nullable<Effect>;
  14408. /**
  14409. * Specifies if the material was previously ready
  14410. */
  14411. _wasPreviouslyReady: boolean;
  14412. /**
  14413. * Specifies if uniform buffers should be used
  14414. */
  14415. private _useUBO;
  14416. /**
  14417. * Stores a reference to the scene
  14418. */
  14419. private _scene;
  14420. /**
  14421. * Stores the fill mode state
  14422. */
  14423. private _fillMode;
  14424. /**
  14425. * Specifies if the depth write state should be cached
  14426. */
  14427. private _cachedDepthWriteState;
  14428. /**
  14429. * Stores the uniform buffer
  14430. */
  14431. protected _uniformBuffer: UniformBuffer;
  14432. /**
  14433. * Creates a material instance
  14434. * @param name defines the name of the material
  14435. * @param scene defines the scene to reference
  14436. * @param doNotAdd specifies if the material should be added to the scene
  14437. */
  14438. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14439. /**
  14440. * Returns a string representation of the current material
  14441. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14442. * @returns a string with material information
  14443. */
  14444. toString(fullDetails?: boolean): string;
  14445. /**
  14446. * Gets the class name of the material
  14447. * @returns a string with the class name of the material
  14448. */
  14449. getClassName(): string;
  14450. /**
  14451. * Specifies if updates for the material been locked
  14452. */
  14453. readonly isFrozen: boolean;
  14454. /**
  14455. * Locks updates for the material
  14456. */
  14457. freeze(): void;
  14458. /**
  14459. * Unlocks updates for the material
  14460. */
  14461. unfreeze(): void;
  14462. /**
  14463. * Specifies if the material is ready to be used
  14464. * @param mesh defines the mesh to check
  14465. * @param useInstances specifies if instances should be used
  14466. * @returns a boolean indicating if the material is ready to be used
  14467. */
  14468. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14469. /**
  14470. * Specifies that the submesh is ready to be used
  14471. * @param mesh defines the mesh to check
  14472. * @param subMesh defines which submesh to check
  14473. * @param useInstances specifies that instances should be used
  14474. * @returns a boolean indicating that the submesh is ready or not
  14475. */
  14476. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14477. /**
  14478. * Returns the material effect
  14479. * @returns the effect associated with the material
  14480. */
  14481. getEffect(): Nullable<Effect>;
  14482. /**
  14483. * Returns the current scene
  14484. * @returns a Scene
  14485. */
  14486. getScene(): Scene;
  14487. /**
  14488. * Specifies if the material will require alpha blending
  14489. * @returns a boolean specifying if alpha blending is needed
  14490. */
  14491. needAlphaBlending(): boolean;
  14492. /**
  14493. * Specifies if the mesh will require alpha blending
  14494. * @param mesh defines the mesh to check
  14495. * @returns a boolean specifying if alpha blending is needed for the mesh
  14496. */
  14497. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14498. /**
  14499. * Specifies if this material should be rendered in alpha test mode
  14500. * @returns a boolean specifying if an alpha test is needed.
  14501. */
  14502. needAlphaTesting(): boolean;
  14503. /**
  14504. * Gets the texture used for the alpha test
  14505. * @returns the texture to use for alpha testing
  14506. */
  14507. getAlphaTestTexture(): Nullable<BaseTexture>;
  14508. /**
  14509. * Marks the material to indicate that it needs to be re-calculated
  14510. */
  14511. markDirty(): void;
  14512. /** @hidden */
  14513. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14514. /**
  14515. * Binds the material to the mesh
  14516. * @param world defines the world transformation matrix
  14517. * @param mesh defines the mesh to bind the material to
  14518. */
  14519. bind(world: Matrix, mesh?: Mesh): void;
  14520. /**
  14521. * Binds the submesh to the material
  14522. * @param world defines the world transformation matrix
  14523. * @param mesh defines the mesh containing the submesh
  14524. * @param subMesh defines the submesh to bind the material to
  14525. */
  14526. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14527. /**
  14528. * Binds the world matrix to the material
  14529. * @param world defines the world transformation matrix
  14530. */
  14531. bindOnlyWorldMatrix(world: Matrix): void;
  14532. /**
  14533. * Binds the scene's uniform buffer to the effect.
  14534. * @param effect defines the effect to bind to the scene uniform buffer
  14535. * @param sceneUbo defines the uniform buffer storing scene data
  14536. */
  14537. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14538. /**
  14539. * Binds the view matrix to the effect
  14540. * @param effect defines the effect to bind the view matrix to
  14541. */
  14542. bindView(effect: Effect): void;
  14543. /**
  14544. * Binds the view projection matrix to the effect
  14545. * @param effect defines the effect to bind the view projection matrix to
  14546. */
  14547. bindViewProjection(effect: Effect): void;
  14548. /**
  14549. * Specifies if material alpha testing should be turned on for the mesh
  14550. * @param mesh defines the mesh to check
  14551. */
  14552. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14553. /**
  14554. * Processes to execute after binding the material to a mesh
  14555. * @param mesh defines the rendered mesh
  14556. */
  14557. protected _afterBind(mesh?: Mesh): void;
  14558. /**
  14559. * Unbinds the material from the mesh
  14560. */
  14561. unbind(): void;
  14562. /**
  14563. * Gets the active textures from the material
  14564. * @returns an array of textures
  14565. */
  14566. getActiveTextures(): BaseTexture[];
  14567. /**
  14568. * Specifies if the material uses a texture
  14569. * @param texture defines the texture to check against the material
  14570. * @returns a boolean specifying if the material uses the texture
  14571. */
  14572. hasTexture(texture: BaseTexture): boolean;
  14573. /**
  14574. * Makes a duplicate of the material, and gives it a new name
  14575. * @param name defines the new name for the duplicated material
  14576. * @returns the cloned material
  14577. */
  14578. clone(name: string): Nullable<Material>;
  14579. /**
  14580. * Gets the meshes bound to the material
  14581. * @returns an array of meshes bound to the material
  14582. */
  14583. getBindedMeshes(): AbstractMesh[];
  14584. /**
  14585. * Force shader compilation
  14586. * @param mesh defines the mesh associated with this material
  14587. * @param onCompiled defines a function to execute once the material is compiled
  14588. * @param options defines the options to configure the compilation
  14589. */
  14590. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14591. clipPlane: boolean;
  14592. }>): void;
  14593. /**
  14594. * Force shader compilation
  14595. * @param mesh defines the mesh that will use this material
  14596. * @param options defines additional options for compiling the shaders
  14597. * @returns a promise that resolves when the compilation completes
  14598. */
  14599. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14600. clipPlane: boolean;
  14601. }>): Promise<void>;
  14602. /**
  14603. * Marks a define in the material to indicate that it needs to be re-computed
  14604. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14605. */
  14606. markAsDirty(flag: number): void;
  14607. /**
  14608. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14609. * @param func defines a function which checks material defines against the submeshes
  14610. */
  14611. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14612. /**
  14613. * Indicates that image processing needs to be re-calculated for all submeshes
  14614. */
  14615. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14616. /**
  14617. * Indicates that textures need to be re-calculated for all submeshes
  14618. */
  14619. protected _markAllSubMeshesAsTexturesDirty(): void;
  14620. /**
  14621. * Indicates that fresnel needs to be re-calculated for all submeshes
  14622. */
  14623. protected _markAllSubMeshesAsFresnelDirty(): void;
  14624. /**
  14625. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14626. */
  14627. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14628. /**
  14629. * Indicates that lights need to be re-calculated for all submeshes
  14630. */
  14631. protected _markAllSubMeshesAsLightsDirty(): void;
  14632. /**
  14633. * Indicates that attributes need to be re-calculated for all submeshes
  14634. */
  14635. protected _markAllSubMeshesAsAttributesDirty(): void;
  14636. /**
  14637. * Indicates that misc needs to be re-calculated for all submeshes
  14638. */
  14639. protected _markAllSubMeshesAsMiscDirty(): void;
  14640. /**
  14641. * Indicates that textures and misc need to be re-calculated for all submeshes
  14642. */
  14643. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14644. /**
  14645. * Disposes the material
  14646. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14647. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14648. */
  14649. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14650. /**
  14651. * Serializes this material
  14652. * @returns the serialized material object
  14653. */
  14654. serialize(): any;
  14655. /**
  14656. * Creates a MultiMaterial from parsed MultiMaterial data.
  14657. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14658. * @param scene defines the hosting scene
  14659. * @returns a new MultiMaterial
  14660. */
  14661. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14662. /**
  14663. * Creates a material from parsed material data
  14664. * @param parsedMaterial defines parsed material data
  14665. * @param scene defines the hosting scene
  14666. * @param rootUrl defines the root URL to use to load textures
  14667. * @returns a new material
  14668. */
  14669. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14670. }
  14671. }
  14672. declare module BABYLON {
  14673. /**
  14674. * "Static Class" containing the most commonly used helper while dealing with material for
  14675. * rendering purpose.
  14676. *
  14677. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14678. *
  14679. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14680. */
  14681. class MaterialHelper {
  14682. /**
  14683. * Bind the current view position to an effect.
  14684. * @param effect The effect to be bound
  14685. * @param scene The scene the eyes position is used from
  14686. */
  14687. static BindEyePosition(effect: Effect, scene: Scene): void;
  14688. /**
  14689. * Helps preparing the defines values about the UVs in used in the effect.
  14690. * UVs are shared as much as we can accross chanels in the shaders.
  14691. * @param texture The texture we are preparing the UVs for
  14692. * @param defines The defines to update
  14693. * @param key The chanel key "diffuse", "specular"... used in the shader
  14694. */
  14695. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14696. /**
  14697. * Binds a texture matrix value to its corrsponding uniform
  14698. * @param texture The texture to bind the matrix for
  14699. * @param uniformBuffer The uniform buffer receivin the data
  14700. * @param key The chanel key "diffuse", "specular"... used in the shader
  14701. */
  14702. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14703. /**
  14704. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14705. * @param mesh defines the current mesh
  14706. * @param scene defines the current scene
  14707. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14708. * @param pointsCloud defines if point cloud rendering has to be turned on
  14709. * @param fogEnabled defines if fog has to be turned on
  14710. * @param alphaTest defines if alpha testing has to be turned on
  14711. * @param defines defines the current list of defines
  14712. */
  14713. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14714. /**
  14715. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14716. * @param scene defines the current scene
  14717. * @param engine defines the current engine
  14718. * @param defines specifies the list of active defines
  14719. * @param useInstances defines if instances have to be turned on
  14720. * @param useClipPlane defines if clip plane have to be turned on
  14721. */
  14722. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14723. /**
  14724. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14725. * @param mesh The mesh containing the geometry data we will draw
  14726. * @param defines The defines to update
  14727. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14728. * @param useBones Precise whether bones should be used or not (override mesh info)
  14729. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14730. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14731. * @returns false if defines are considered not dirty and have not been checked
  14732. */
  14733. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14734. /**
  14735. * Prepares the defines related to the light information passed in parameter
  14736. * @param scene The scene we are intending to draw
  14737. * @param mesh The mesh the effect is compiling for
  14738. * @param defines The defines to update
  14739. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14740. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14741. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14742. * @returns true if normals will be required for the rest of the effect
  14743. */
  14744. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14745. /**
  14746. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14747. * that won t be acctive due to defines being turned off.
  14748. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14749. * @param samplersList The samplers list
  14750. * @param defines The defines helping in the list generation
  14751. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14752. */
  14753. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14754. /**
  14755. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14756. * @param defines The defines to update while falling back
  14757. * @param fallbacks The authorized effect fallbacks
  14758. * @param maxSimultaneousLights The maximum number of lights allowed
  14759. * @param rank the current rank of the Effect
  14760. * @returns The newly affected rank
  14761. */
  14762. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14763. /**
  14764. * Prepares the list of attributes required for morph targets according to the effect defines.
  14765. * @param attribs The current list of supported attribs
  14766. * @param mesh The mesh to prepare the morph targets attributes for
  14767. * @param defines The current Defines of the effect
  14768. */
  14769. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14770. /**
  14771. * Prepares the list of attributes required for bones according to the effect defines.
  14772. * @param attribs The current list of supported attribs
  14773. * @param mesh The mesh to prepare the bones attributes for
  14774. * @param defines The current Defines of the effect
  14775. * @param fallbacks The current efffect fallback strategy
  14776. */
  14777. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14778. /**
  14779. * Prepares the list of attributes required for instances according to the effect defines.
  14780. * @param attribs The current list of supported attribs
  14781. * @param defines The current Defines of the effect
  14782. */
  14783. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14784. /**
  14785. * Binds the light shadow information to the effect for the given mesh.
  14786. * @param light The light containing the generator
  14787. * @param scene The scene the lights belongs to
  14788. * @param mesh The mesh we are binding the information to render
  14789. * @param lightIndex The light index in the effect used to render the mesh
  14790. * @param effect The effect we are binding the data to
  14791. */
  14792. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14793. /**
  14794. * Binds the light information to the effect.
  14795. * @param light The light containing the generator
  14796. * @param effect The effect we are binding the data to
  14797. * @param lightIndex The light index in the effect used to render
  14798. */
  14799. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14800. /**
  14801. * Binds the lights information from the scene to the effect for the given mesh.
  14802. * @param scene The scene the lights belongs to
  14803. * @param mesh The mesh we are binding the information to render
  14804. * @param effect The effect we are binding the data to
  14805. * @param defines The generated defines for the effect
  14806. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14807. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14808. */
  14809. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14810. /**
  14811. * Binds the fog information from the scene to the effect for the given mesh.
  14812. * @param scene The scene the lights belongs to
  14813. * @param mesh The mesh we are binding the information to render
  14814. * @param effect The effect we are binding the data to
  14815. */
  14816. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14817. /**
  14818. * Binds the bones information from the mesh to the effect.
  14819. * @param mesh The mesh we are binding the information to render
  14820. * @param effect The effect we are binding the data to
  14821. */
  14822. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14823. /**
  14824. * Binds the morph targets information from the mesh to the effect.
  14825. * @param abstractMesh The mesh we are binding the information to render
  14826. * @param effect The effect we are binding the data to
  14827. */
  14828. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14829. /**
  14830. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14831. * @param defines The generated defines used in the effect
  14832. * @param effect The effect we are binding the data to
  14833. * @param scene The scene we are willing to render with logarithmic scale for
  14834. */
  14835. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14836. /**
  14837. * Binds the clip plane information from the scene to the effect.
  14838. * @param scene The scene the clip plane information are extracted from
  14839. * @param effect The effect we are binding the data to
  14840. */
  14841. static BindClipPlane(effect: Effect, scene: Scene): void;
  14842. }
  14843. }
  14844. declare module BABYLON {
  14845. class MultiMaterial extends Material {
  14846. private _subMaterials;
  14847. subMaterials: Nullable<Material>[];
  14848. constructor(name: string, scene: Scene);
  14849. private _hookArray;
  14850. getSubMaterial(index: number): Nullable<Material>;
  14851. getActiveTextures(): BaseTexture[];
  14852. getClassName(): string;
  14853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14854. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14855. serialize(): any;
  14856. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14857. }
  14858. }
  14859. declare module BABYLON {
  14860. class PushMaterial extends Material {
  14861. protected _activeEffect: Effect;
  14862. protected _normalMatrix: Matrix;
  14863. constructor(name: string, scene: Scene);
  14864. getEffect(): Effect;
  14865. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14866. /**
  14867. * Binds the given world matrix to the active effect
  14868. *
  14869. * @param world the matrix to bind
  14870. */
  14871. bindOnlyWorldMatrix(world: Matrix): void;
  14872. /**
  14873. * Binds the given normal matrix to the active effect
  14874. *
  14875. * @param normalMatrix the matrix to bind
  14876. */
  14877. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14878. bind(world: Matrix, mesh?: Mesh): void;
  14879. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14880. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14881. }
  14882. }
  14883. declare module BABYLON {
  14884. class ShaderMaterial extends Material {
  14885. private _shaderPath;
  14886. private _options;
  14887. private _textures;
  14888. private _textureArrays;
  14889. private _floats;
  14890. private _ints;
  14891. private _floatsArrays;
  14892. private _colors3;
  14893. private _colors3Arrays;
  14894. private _colors4;
  14895. private _vectors2;
  14896. private _vectors3;
  14897. private _vectors4;
  14898. private _matrices;
  14899. private _matrices3x3;
  14900. private _matrices2x2;
  14901. private _vectors2Arrays;
  14902. private _vectors3Arrays;
  14903. private _cachedWorldViewMatrix;
  14904. private _renderId;
  14905. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14906. getClassName(): string;
  14907. needAlphaBlending(): boolean;
  14908. needAlphaTesting(): boolean;
  14909. private _checkUniform;
  14910. setTexture(name: string, texture: Texture): ShaderMaterial;
  14911. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14912. setFloat(name: string, value: number): ShaderMaterial;
  14913. setInt(name: string, value: number): ShaderMaterial;
  14914. setFloats(name: string, value: number[]): ShaderMaterial;
  14915. setColor3(name: string, value: Color3): ShaderMaterial;
  14916. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14917. setColor4(name: string, value: Color4): ShaderMaterial;
  14918. setVector2(name: string, value: Vector2): ShaderMaterial;
  14919. setVector3(name: string, value: Vector3): ShaderMaterial;
  14920. setVector4(name: string, value: Vector4): ShaderMaterial;
  14921. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14922. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14923. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14924. setArray2(name: string, value: number[]): ShaderMaterial;
  14925. setArray3(name: string, value: number[]): ShaderMaterial;
  14926. private _checkCache;
  14927. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14928. bindOnlyWorldMatrix(world: Matrix): void;
  14929. bind(world: Matrix, mesh?: Mesh): void;
  14930. getActiveTextures(): BaseTexture[];
  14931. hasTexture(texture: BaseTexture): boolean;
  14932. clone(name: string): ShaderMaterial;
  14933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14934. serialize(): any;
  14935. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14936. }
  14937. }
  14938. declare module BABYLON {
  14939. /** @hidden */
  14940. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14941. MAINUV1: boolean;
  14942. MAINUV2: boolean;
  14943. DIFFUSE: boolean;
  14944. DIFFUSEDIRECTUV: number;
  14945. AMBIENT: boolean;
  14946. AMBIENTDIRECTUV: number;
  14947. OPACITY: boolean;
  14948. OPACITYDIRECTUV: number;
  14949. OPACITYRGB: boolean;
  14950. REFLECTION: boolean;
  14951. EMISSIVE: boolean;
  14952. EMISSIVEDIRECTUV: number;
  14953. SPECULAR: boolean;
  14954. SPECULARDIRECTUV: number;
  14955. BUMP: boolean;
  14956. BUMPDIRECTUV: number;
  14957. PARALLAX: boolean;
  14958. PARALLAXOCCLUSION: boolean;
  14959. SPECULAROVERALPHA: boolean;
  14960. CLIPPLANE: boolean;
  14961. ALPHATEST: boolean;
  14962. DEPTHPREPASS: boolean;
  14963. ALPHAFROMDIFFUSE: boolean;
  14964. POINTSIZE: boolean;
  14965. FOG: boolean;
  14966. SPECULARTERM: boolean;
  14967. DIFFUSEFRESNEL: boolean;
  14968. OPACITYFRESNEL: boolean;
  14969. REFLECTIONFRESNEL: boolean;
  14970. REFRACTIONFRESNEL: boolean;
  14971. EMISSIVEFRESNEL: boolean;
  14972. FRESNEL: boolean;
  14973. NORMAL: boolean;
  14974. UV1: boolean;
  14975. UV2: boolean;
  14976. VERTEXCOLOR: boolean;
  14977. VERTEXALPHA: boolean;
  14978. NUM_BONE_INFLUENCERS: number;
  14979. BonesPerMesh: number;
  14980. INSTANCES: boolean;
  14981. GLOSSINESS: boolean;
  14982. ROUGHNESS: boolean;
  14983. EMISSIVEASILLUMINATION: boolean;
  14984. LINKEMISSIVEWITHDIFFUSE: boolean;
  14985. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14986. LIGHTMAP: boolean;
  14987. LIGHTMAPDIRECTUV: number;
  14988. OBJECTSPACE_NORMALMAP: boolean;
  14989. USELIGHTMAPASSHADOWMAP: boolean;
  14990. REFLECTIONMAP_3D: boolean;
  14991. REFLECTIONMAP_SPHERICAL: boolean;
  14992. REFLECTIONMAP_PLANAR: boolean;
  14993. REFLECTIONMAP_CUBIC: boolean;
  14994. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14995. REFLECTIONMAP_PROJECTION: boolean;
  14996. REFLECTIONMAP_SKYBOX: boolean;
  14997. REFLECTIONMAP_EXPLICIT: boolean;
  14998. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14999. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  15000. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  15001. INVERTCUBICMAP: boolean;
  15002. LOGARITHMICDEPTH: boolean;
  15003. REFRACTION: boolean;
  15004. REFRACTIONMAP_3D: boolean;
  15005. REFLECTIONOVERALPHA: boolean;
  15006. TWOSIDEDLIGHTING: boolean;
  15007. SHADOWFLOAT: boolean;
  15008. MORPHTARGETS: boolean;
  15009. MORPHTARGETS_NORMAL: boolean;
  15010. MORPHTARGETS_TANGENT: boolean;
  15011. NUM_MORPH_INFLUENCERS: number;
  15012. NONUNIFORMSCALING: boolean;
  15013. PREMULTIPLYALPHA: boolean;
  15014. IMAGEPROCESSING: boolean;
  15015. VIGNETTE: boolean;
  15016. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15017. VIGNETTEBLENDMODEOPAQUE: boolean;
  15018. TONEMAPPING: boolean;
  15019. TONEMAPPING_ACES: boolean;
  15020. CONTRAST: boolean;
  15021. COLORCURVES: boolean;
  15022. COLORGRADING: boolean;
  15023. COLORGRADING3D: boolean;
  15024. SAMPLER3DGREENDEPTH: boolean;
  15025. SAMPLER3DBGRMAP: boolean;
  15026. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15027. /**
  15028. * If the reflection texture on this material is in linear color space
  15029. * @hidden
  15030. */
  15031. IS_REFLECTION_LINEAR: boolean;
  15032. /**
  15033. * If the refraction texture on this material is in linear color space
  15034. * @hidden
  15035. */
  15036. IS_REFRACTION_LINEAR: boolean;
  15037. EXPOSURE: boolean;
  15038. constructor();
  15039. setReflectionMode(modeToEnable: string): void;
  15040. }
  15041. class StandardMaterial extends PushMaterial {
  15042. private _diffuseTexture;
  15043. diffuseTexture: Nullable<BaseTexture>;
  15044. private _ambientTexture;
  15045. ambientTexture: Nullable<BaseTexture>;
  15046. private _opacityTexture;
  15047. opacityTexture: Nullable<BaseTexture>;
  15048. private _reflectionTexture;
  15049. reflectionTexture: Nullable<BaseTexture>;
  15050. private _emissiveTexture;
  15051. emissiveTexture: Nullable<BaseTexture>;
  15052. private _specularTexture;
  15053. specularTexture: Nullable<BaseTexture>;
  15054. private _bumpTexture;
  15055. bumpTexture: Nullable<BaseTexture>;
  15056. private _lightmapTexture;
  15057. lightmapTexture: Nullable<BaseTexture>;
  15058. private _refractionTexture;
  15059. refractionTexture: Nullable<BaseTexture>;
  15060. ambientColor: Color3;
  15061. diffuseColor: Color3;
  15062. specularColor: Color3;
  15063. emissiveColor: Color3;
  15064. specularPower: number;
  15065. private _useAlphaFromDiffuseTexture;
  15066. useAlphaFromDiffuseTexture: boolean;
  15067. private _useEmissiveAsIllumination;
  15068. useEmissiveAsIllumination: boolean;
  15069. private _linkEmissiveWithDiffuse;
  15070. linkEmissiveWithDiffuse: boolean;
  15071. private _useSpecularOverAlpha;
  15072. useSpecularOverAlpha: boolean;
  15073. private _useReflectionOverAlpha;
  15074. useReflectionOverAlpha: boolean;
  15075. private _disableLighting;
  15076. disableLighting: boolean;
  15077. private _useObjectSpaceNormalMap;
  15078. /**
  15079. * Allows using an object space normal map (instead of tangent space).
  15080. */
  15081. useObjectSpaceNormalMap: boolean;
  15082. private _useParallax;
  15083. useParallax: boolean;
  15084. private _useParallaxOcclusion;
  15085. useParallaxOcclusion: boolean;
  15086. parallaxScaleBias: number;
  15087. private _roughness;
  15088. roughness: number;
  15089. indexOfRefraction: number;
  15090. invertRefractionY: boolean;
  15091. /**
  15092. * Defines the alpha limits in alpha test mode
  15093. */
  15094. alphaCutOff: number;
  15095. private _useLightmapAsShadowmap;
  15096. useLightmapAsShadowmap: boolean;
  15097. private _diffuseFresnelParameters;
  15098. diffuseFresnelParameters: FresnelParameters;
  15099. private _opacityFresnelParameters;
  15100. opacityFresnelParameters: FresnelParameters;
  15101. private _reflectionFresnelParameters;
  15102. reflectionFresnelParameters: FresnelParameters;
  15103. private _refractionFresnelParameters;
  15104. refractionFresnelParameters: FresnelParameters;
  15105. private _emissiveFresnelParameters;
  15106. emissiveFresnelParameters: FresnelParameters;
  15107. private _useReflectionFresnelFromSpecular;
  15108. useReflectionFresnelFromSpecular: boolean;
  15109. private _useGlossinessFromSpecularMapAlpha;
  15110. useGlossinessFromSpecularMapAlpha: boolean;
  15111. private _maxSimultaneousLights;
  15112. maxSimultaneousLights: number;
  15113. /**
  15114. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  15115. */
  15116. private _invertNormalMapX;
  15117. invertNormalMapX: boolean;
  15118. /**
  15119. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  15120. */
  15121. private _invertNormalMapY;
  15122. invertNormalMapY: boolean;
  15123. /**
  15124. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  15125. */
  15126. private _twoSidedLighting;
  15127. twoSidedLighting: boolean;
  15128. /**
  15129. * Default configuration related to image processing available in the standard Material.
  15130. */
  15131. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15132. /**
  15133. * Gets the image processing configuration used either in this material.
  15134. */
  15135. /**
  15136. * Sets the Default image processing configuration used either in the this material.
  15137. *
  15138. * If sets to null, the scene one is in use.
  15139. */
  15140. imageProcessingConfiguration: ImageProcessingConfiguration;
  15141. /**
  15142. * Keep track of the image processing observer to allow dispose and replace.
  15143. */
  15144. private _imageProcessingObserver;
  15145. /**
  15146. * Attaches a new image processing configuration to the Standard Material.
  15147. * @param configuration
  15148. */
  15149. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15150. /**
  15151. * Gets wether the color curves effect is enabled.
  15152. */
  15153. /**
  15154. * Sets wether the color curves effect is enabled.
  15155. */
  15156. cameraColorCurvesEnabled: boolean;
  15157. /**
  15158. * Gets wether the color grading effect is enabled.
  15159. */
  15160. /**
  15161. * Gets wether the color grading effect is enabled.
  15162. */
  15163. cameraColorGradingEnabled: boolean;
  15164. /**
  15165. * Gets wether tonemapping is enabled or not.
  15166. */
  15167. /**
  15168. * Sets wether tonemapping is enabled or not
  15169. */
  15170. cameraToneMappingEnabled: boolean;
  15171. /**
  15172. * The camera exposure used on this material.
  15173. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15174. * This corresponds to a photographic exposure.
  15175. */
  15176. /**
  15177. * The camera exposure used on this material.
  15178. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15179. * This corresponds to a photographic exposure.
  15180. */
  15181. cameraExposure: number;
  15182. /**
  15183. * Gets The camera contrast used on this material.
  15184. */
  15185. /**
  15186. * Sets The camera contrast used on this material.
  15187. */
  15188. cameraContrast: number;
  15189. /**
  15190. * Gets the Color Grading 2D Lookup Texture.
  15191. */
  15192. /**
  15193. * Sets the Color Grading 2D Lookup Texture.
  15194. */
  15195. cameraColorGradingTexture: Nullable<BaseTexture>;
  15196. /**
  15197. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15198. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15199. * 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;
  15200. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15201. */
  15202. /**
  15203. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15204. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15205. * 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;
  15206. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15207. */
  15208. cameraColorCurves: Nullable<ColorCurves>;
  15209. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  15210. protected _renderTargets: SmartArray<RenderTargetTexture>;
  15211. protected _worldViewProjectionMatrix: Matrix;
  15212. protected _globalAmbientColor: Color3;
  15213. protected _useLogarithmicDepth: boolean;
  15214. constructor(name: string, scene: Scene);
  15215. getClassName(): string;
  15216. useLogarithmicDepth: boolean;
  15217. needAlphaBlending(): boolean;
  15218. needAlphaTesting(): boolean;
  15219. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15220. getAlphaTestTexture(): Nullable<BaseTexture>;
  15221. /**
  15222. * Child classes can use it to update shaders
  15223. */
  15224. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15225. buildUniformLayout(): void;
  15226. unbind(): void;
  15227. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15228. getAnimatables(): IAnimatable[];
  15229. getActiveTextures(): BaseTexture[];
  15230. hasTexture(texture: BaseTexture): boolean;
  15231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15232. clone(name: string): StandardMaterial;
  15233. serialize(): any;
  15234. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15235. static _DiffuseTextureEnabled: boolean;
  15236. static DiffuseTextureEnabled: boolean;
  15237. static _AmbientTextureEnabled: boolean;
  15238. static AmbientTextureEnabled: boolean;
  15239. static _OpacityTextureEnabled: boolean;
  15240. static OpacityTextureEnabled: boolean;
  15241. static _ReflectionTextureEnabled: boolean;
  15242. static ReflectionTextureEnabled: boolean;
  15243. static _EmissiveTextureEnabled: boolean;
  15244. static EmissiveTextureEnabled: boolean;
  15245. static _SpecularTextureEnabled: boolean;
  15246. static SpecularTextureEnabled: boolean;
  15247. static _BumpTextureEnabled: boolean;
  15248. static BumpTextureEnabled: boolean;
  15249. static _LightmapTextureEnabled: boolean;
  15250. static LightmapTextureEnabled: boolean;
  15251. static _RefractionTextureEnabled: boolean;
  15252. static RefractionTextureEnabled: boolean;
  15253. static _ColorGradingTextureEnabled: boolean;
  15254. static ColorGradingTextureEnabled: boolean;
  15255. static _FresnelEnabled: boolean;
  15256. static FresnelEnabled: boolean;
  15257. }
  15258. }
  15259. declare module BABYLON {
  15260. class UniformBuffer {
  15261. private _engine;
  15262. private _buffer;
  15263. private _data;
  15264. private _bufferData;
  15265. private _dynamic?;
  15266. private _uniformLocations;
  15267. private _uniformSizes;
  15268. private _uniformLocationPointer;
  15269. private _needSync;
  15270. private _noUBO;
  15271. private _currentEffect;
  15272. private static _MAX_UNIFORM_SIZE;
  15273. private static _tempBuffer;
  15274. /**
  15275. * Wrapper for updateUniform.
  15276. * @method updateMatrix3x3
  15277. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15278. * @param {Float32Array} matrix
  15279. */
  15280. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15281. /**
  15282. * Wrapper for updateUniform.
  15283. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15284. * @param {Float32Array} matrix
  15285. */
  15286. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15287. /**
  15288. * Wrapper for updateUniform.
  15289. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15290. * @param {number} x
  15291. */
  15292. updateFloat: (name: string, x: number) => void;
  15293. /**
  15294. * Wrapper for updateUniform.
  15295. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15296. * @param {number} x
  15297. * @param {number} y
  15298. * @param {string} [suffix] Suffix to add to the uniform name.
  15299. */
  15300. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15301. /**
  15302. * Wrapper for updateUniform.
  15303. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15304. * @param {number} x
  15305. * @param {number} y
  15306. * @param {number} z
  15307. * @param {string} [suffix] Suffix to add to the uniform name.
  15308. */
  15309. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15310. /**
  15311. * Wrapper for updateUniform.
  15312. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15313. * @param {number} x
  15314. * @param {number} y
  15315. * @param {number} z
  15316. * @param {number} w
  15317. * @param {string} [suffix] Suffix to add to the uniform name.
  15318. */
  15319. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15320. /**
  15321. * Wrapper for updateUniform.
  15322. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15323. * @param {Matrix} A 4x4 matrix.
  15324. */
  15325. updateMatrix: (name: string, mat: Matrix) => void;
  15326. /**
  15327. * Wrapper for updateUniform.
  15328. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15329. * @param {Vector3} vector
  15330. */
  15331. updateVector3: (name: string, vector: Vector3) => void;
  15332. /**
  15333. * Wrapper for updateUniform.
  15334. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15335. * @param {Vector4} vector
  15336. */
  15337. updateVector4: (name: string, vector: Vector4) => void;
  15338. /**
  15339. * Wrapper for updateUniform.
  15340. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15341. * @param {Color3} color
  15342. * @param {string} [suffix] Suffix to add to the uniform name.
  15343. */
  15344. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15345. /**
  15346. * Wrapper for updateUniform.
  15347. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15348. * @param {Color3} color
  15349. * @param {number} alpha
  15350. * @param {string} [suffix] Suffix to add to the uniform name.
  15351. */
  15352. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15353. /**
  15354. * Uniform buffer objects.
  15355. *
  15356. * Handles blocks of uniform on the GPU.
  15357. *
  15358. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15359. *
  15360. * For more information, please refer to :
  15361. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15362. */
  15363. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15364. /**
  15365. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15366. * or just falling back on setUniformXXX calls.
  15367. */
  15368. readonly useUbo: boolean;
  15369. /**
  15370. * Indicates if the WebGL underlying uniform buffer is in sync
  15371. * with the javascript cache data.
  15372. */
  15373. readonly isSync: boolean;
  15374. /**
  15375. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15376. * Also, a dynamic UniformBuffer will disable cache verification and always
  15377. * update the underlying WebGL uniform buffer to the GPU.
  15378. */
  15379. isDynamic(): boolean;
  15380. /**
  15381. * The data cache on JS side.
  15382. */
  15383. getData(): Float32Array;
  15384. /**
  15385. * The underlying WebGL Uniform buffer.
  15386. */
  15387. getBuffer(): Nullable<WebGLBuffer>;
  15388. /**
  15389. * std140 layout specifies how to align data within an UBO structure.
  15390. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15391. * for specs.
  15392. */
  15393. private _fillAlignment;
  15394. /**
  15395. * Adds an uniform in the buffer.
  15396. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15397. * for the layout to be correct !
  15398. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15399. * @param {number|number[]} size Data size, or data directly.
  15400. */
  15401. addUniform(name: string, size: number | number[]): void;
  15402. /**
  15403. * Wrapper for addUniform.
  15404. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15405. * @param {Matrix} mat A 4x4 matrix.
  15406. */
  15407. addMatrix(name: string, mat: Matrix): void;
  15408. /**
  15409. * Wrapper for addUniform.
  15410. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15411. * @param {number} x
  15412. * @param {number} y
  15413. */
  15414. addFloat2(name: string, x: number, y: number): void;
  15415. /**
  15416. * Wrapper for addUniform.
  15417. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15418. * @param {number} x
  15419. * @param {number} y
  15420. * @param {number} z
  15421. */
  15422. addFloat3(name: string, x: number, y: number, z: number): void;
  15423. /**
  15424. * Wrapper for addUniform.
  15425. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15426. * @param {Color3} color
  15427. */
  15428. addColor3(name: string, color: Color3): void;
  15429. /**
  15430. * Wrapper for addUniform.
  15431. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15432. * @param {Color3} color
  15433. * @param {number} alpha
  15434. */
  15435. addColor4(name: string, color: Color3, alpha: number): void;
  15436. /**
  15437. * Wrapper for addUniform.
  15438. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15439. * @param {Vector3} vector
  15440. */
  15441. addVector3(name: string, vector: Vector3): void;
  15442. /**
  15443. * Wrapper for addUniform.
  15444. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15445. */
  15446. addMatrix3x3(name: string): void;
  15447. /**
  15448. * Wrapper for addUniform.
  15449. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15450. */
  15451. addMatrix2x2(name: string): void;
  15452. /**
  15453. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15454. */
  15455. create(): void;
  15456. _rebuild(): void;
  15457. /**
  15458. * Updates the WebGL Uniform Buffer on the GPU.
  15459. * If the `dynamic` flag is set to true, no cache comparison is done.
  15460. * Otherwise, the buffer will be updated only if the cache differs.
  15461. */
  15462. update(): void;
  15463. /**
  15464. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15465. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15466. * @param {number[]|Float32Array} data Flattened data
  15467. * @param {number} size Size of the data.
  15468. */
  15469. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15470. private _updateMatrix3x3ForUniform;
  15471. private _updateMatrix3x3ForEffect;
  15472. private _updateMatrix2x2ForEffect;
  15473. private _updateMatrix2x2ForUniform;
  15474. private _updateFloatForEffect;
  15475. private _updateFloatForUniform;
  15476. private _updateFloat2ForEffect;
  15477. private _updateFloat2ForUniform;
  15478. private _updateFloat3ForEffect;
  15479. private _updateFloat3ForUniform;
  15480. private _updateFloat4ForEffect;
  15481. private _updateFloat4ForUniform;
  15482. private _updateMatrixForEffect;
  15483. private _updateMatrixForUniform;
  15484. private _updateVector3ForEffect;
  15485. private _updateVector3ForUniform;
  15486. private _updateVector4ForEffect;
  15487. private _updateVector4ForUniform;
  15488. private _updateColor3ForEffect;
  15489. private _updateColor3ForUniform;
  15490. private _updateColor4ForEffect;
  15491. private _updateColor4ForUniform;
  15492. /**
  15493. * Sets a sampler uniform on the effect.
  15494. * @param {string} name Name of the sampler.
  15495. * @param {Texture} texture
  15496. */
  15497. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15498. /**
  15499. * Directly updates the value of the uniform in the cache AND on the GPU.
  15500. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15501. * @param {number[]|Float32Array} data Flattened data
  15502. */
  15503. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15504. /**
  15505. * Binds this uniform buffer to an effect.
  15506. * @param {Effect} effect
  15507. * @param {string} name Name of the uniform block in the shader.
  15508. */
  15509. bindToEffect(effect: Effect, name: string): void;
  15510. /**
  15511. * Disposes the uniform buffer.
  15512. */
  15513. dispose(): void;
  15514. }
  15515. }
  15516. declare module BABYLON {
  15517. class Scalar {
  15518. /**
  15519. * Two pi constants convenient for computation.
  15520. */
  15521. static TwoPi: number;
  15522. /**
  15523. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15524. */
  15525. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15526. /**
  15527. * Returns a string : the upper case translation of the number i to hexadecimal.
  15528. */
  15529. static ToHex(i: number): string;
  15530. /**
  15531. * Returns -1 if value is negative and +1 is value is positive.
  15532. * Returns the value itself if it's equal to zero.
  15533. */
  15534. static Sign(value: number): number;
  15535. /**
  15536. * Returns the value itself if it's between min and max.
  15537. * Returns min if the value is lower than min.
  15538. * Returns max if the value is greater than max.
  15539. */
  15540. static Clamp(value: number, min?: number, max?: number): number;
  15541. /**
  15542. * Returns the log2 of value.
  15543. */
  15544. static Log2(value: number): number;
  15545. /**
  15546. * Loops the value, so that it is never larger than length and never smaller than 0.
  15547. *
  15548. * This is similar to the modulo operator but it works with floating point numbers.
  15549. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15550. * With t = 5 and length = 2.5, the result would be 0.0.
  15551. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15552. */
  15553. static Repeat(value: number, length: number): number;
  15554. /**
  15555. * Normalize the value between 0.0 and 1.0 using min and max values
  15556. */
  15557. static Normalize(value: number, min: number, max: number): number;
  15558. /**
  15559. * Denormalize the value from 0.0 and 1.0 using min and max values
  15560. */
  15561. static Denormalize(normalized: number, min: number, max: number): number;
  15562. /**
  15563. * Calculates the shortest difference between two given angles given in degrees.
  15564. */
  15565. static DeltaAngle(current: number, target: number): number;
  15566. /**
  15567. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15568. *
  15569. * The returned value will move back and forth between 0 and length
  15570. */
  15571. static PingPong(tx: number, length: number): number;
  15572. /**
  15573. * Interpolates between min and max with smoothing at the limits.
  15574. *
  15575. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15576. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15577. */
  15578. static SmoothStep(from: number, to: number, tx: number): number;
  15579. /**
  15580. * Moves a value current towards target.
  15581. *
  15582. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15583. * Negative values of maxDelta pushes the value away from target.
  15584. */
  15585. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15586. /**
  15587. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15588. *
  15589. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15590. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15591. */
  15592. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15593. /**
  15594. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15595. */
  15596. static Lerp(start: number, end: number, amount: number): number;
  15597. /**
  15598. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15599. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15600. */
  15601. static LerpAngle(start: number, end: number, amount: number): number;
  15602. /**
  15603. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15604. */
  15605. static InverseLerp(a: number, b: number, value: number): number;
  15606. /**
  15607. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15608. */
  15609. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15610. /**
  15611. * Returns a random float number between and min and max values
  15612. */
  15613. static RandomRange(min: number, max: number): number;
  15614. /**
  15615. * This function returns percentage of a number in a given range.
  15616. *
  15617. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15618. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15619. */
  15620. static RangeToPercent(number: number, min: number, max: number): number;
  15621. /**
  15622. * This function returns number that corresponds to the percentage in a given range.
  15623. *
  15624. * PercentToRange(0.34,0,100) will return 34.
  15625. */
  15626. static PercentToRange(percent: number, min: number, max: number): number;
  15627. /**
  15628. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15629. * @param angle The angle to normalize in radian.
  15630. * @return The converted angle.
  15631. */
  15632. static NormalizeRadians(angle: number): number;
  15633. }
  15634. }
  15635. declare module BABYLON {
  15636. const ToGammaSpace: number;
  15637. const ToLinearSpace = 2.2;
  15638. const Epsilon = 0.001;
  15639. /**
  15640. * Class used to hold a RBG color
  15641. */
  15642. class Color3 {
  15643. /**
  15644. * Defines the red component (between 0 and 1, default is 0)
  15645. */
  15646. r: number;
  15647. /**
  15648. * Defines the green component (between 0 and 1, default is 0)
  15649. */
  15650. g: number;
  15651. /**
  15652. * Defines the blue component (between 0 and 1, default is 0)
  15653. */
  15654. b: number;
  15655. /**
  15656. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15657. * @param r defines the red component (between 0 and 1, default is 0)
  15658. * @param g defines the green component (between 0 and 1, default is 0)
  15659. * @param b defines the blue component (between 0 and 1, default is 0)
  15660. */
  15661. constructor(
  15662. /**
  15663. * Defines the red component (between 0 and 1, default is 0)
  15664. */
  15665. r?: number,
  15666. /**
  15667. * Defines the green component (between 0 and 1, default is 0)
  15668. */
  15669. g?: number,
  15670. /**
  15671. * Defines the blue component (between 0 and 1, default is 0)
  15672. */
  15673. b?: number);
  15674. /**
  15675. * Creates a string with the Color3 current values
  15676. * @returns the string representation of the Color3 object
  15677. */
  15678. toString(): string;
  15679. /**
  15680. * Returns the string "Color3"
  15681. * @returns "Color3"
  15682. */
  15683. getClassName(): string;
  15684. /**
  15685. * Compute the Color3 hash code
  15686. * @returns an unique number that can be used to hash Color3 objects
  15687. */
  15688. getHashCode(): number;
  15689. /**
  15690. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15691. * @param array defines the array where to store the r,g,b components
  15692. * @param index defines an optional index in the target array to define where to start storing values
  15693. * @returns the current Color3 object
  15694. */
  15695. toArray(array: FloatArray, index?: number): Color3;
  15696. /**
  15697. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15698. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15699. * @returns a new {BABYLON.Color4} object
  15700. */
  15701. toColor4(alpha?: number): Color4;
  15702. /**
  15703. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15704. * @returns the new array
  15705. */
  15706. asArray(): number[];
  15707. /**
  15708. * Returns the luminance value
  15709. * @returns a float value
  15710. */
  15711. toLuminance(): number;
  15712. /**
  15713. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15714. * @param otherColor defines the second operand
  15715. * @returns the new Color3 object
  15716. */
  15717. multiply(otherColor: Color3): Color3;
  15718. /**
  15719. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15720. * @param otherColor defines the second operand
  15721. * @param result defines the Color3 object where to store the result
  15722. * @returns the current Color3
  15723. */
  15724. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15725. /**
  15726. * Determines equality between Color3 objects
  15727. * @param otherColor defines the second operand
  15728. * @returns true if the rgb values are equal to the given ones
  15729. */
  15730. equals(otherColor: Color3): boolean;
  15731. /**
  15732. * Determines equality between the current Color3 object and a set of r,b,g values
  15733. * @param r defines the red component to check
  15734. * @param g defines the green component to check
  15735. * @param b defines the blue component to check
  15736. * @returns true if the rgb values are equal to the given ones
  15737. */
  15738. equalsFloats(r: number, g: number, b: number): boolean;
  15739. /**
  15740. * Multiplies in place each rgb value by scale
  15741. * @param scale defines the scaling factor
  15742. * @returns the updated Color3
  15743. */
  15744. scale(scale: number): Color3;
  15745. /**
  15746. * Multiplies the rgb values by scale and stores the result into "result"
  15747. * @param scale defines the scaling factor
  15748. * @param result defines the Color3 object where to store the result
  15749. * @returns the unmodified current Color3
  15750. */
  15751. scaleToRef(scale: number, result: Color3): Color3;
  15752. /**
  15753. * Scale the current Color3 values by a factor and add the result to a given Color3
  15754. * @param scale defines the scale factor
  15755. * @param result defines color to store the result into
  15756. * @returns the unmodified current Color3
  15757. */
  15758. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15759. /**
  15760. * Clamps the rgb values by the min and max values and stores the result into "result"
  15761. * @param min defines minimum clamping value (default is 0)
  15762. * @param max defines maximum clamping value (default is 1)
  15763. * @param result defines color to store the result into
  15764. * @returns the original Color3
  15765. */
  15766. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15767. /**
  15768. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15769. * @param otherColor defines the second operand
  15770. * @returns the new Color3
  15771. */
  15772. add(otherColor: Color3): Color3;
  15773. /**
  15774. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15775. * @param otherColor defines the second operand
  15776. * @param result defines Color3 object to store the result into
  15777. * @returns the unmodified current Color3
  15778. */
  15779. addToRef(otherColor: Color3, result: Color3): Color3;
  15780. /**
  15781. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15782. * @param otherColor defines the second operand
  15783. * @returns the new Color3
  15784. */
  15785. subtract(otherColor: Color3): Color3;
  15786. /**
  15787. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15788. * @param otherColor defines the second operand
  15789. * @param result defines Color3 object to store the result into
  15790. * @returns the unmodified current Color3
  15791. */
  15792. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15793. /**
  15794. * Copy the current object
  15795. * @returns a new Color3 copied the current one
  15796. */
  15797. clone(): Color3;
  15798. /**
  15799. * Copies the rgb values from the source in the current Color3
  15800. * @param source defines the source Color3 object
  15801. * @returns the updated Color3 object
  15802. */
  15803. copyFrom(source: Color3): Color3;
  15804. /**
  15805. * Updates the Color3 rgb values from the given floats
  15806. * @param r defines the red component to read from
  15807. * @param g defines the green component to read from
  15808. * @param b defines the blue component to read from
  15809. * @returns the current Color3 object
  15810. */
  15811. copyFromFloats(r: number, g: number, b: number): Color3;
  15812. /**
  15813. * Updates the Color3 rgb values from the given floats
  15814. * @param r defines the red component to read from
  15815. * @param g defines the green component to read from
  15816. * @param b defines the blue component to read from
  15817. * @returns the current Color3 object
  15818. */
  15819. set(r: number, g: number, b: number): Color3;
  15820. /**
  15821. * Compute the Color3 hexadecimal code as a string
  15822. * @returns a string containing the hexadecimal representation of the Color3 object
  15823. */
  15824. toHexString(): string;
  15825. /**
  15826. * Computes a new Color3 converted from the current one to linear space
  15827. * @returns a new Color3 object
  15828. */
  15829. toLinearSpace(): Color3;
  15830. /**
  15831. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15832. * @param convertedColor defines the Color3 object where to store the linear space version
  15833. * @returns the unmodified Color3
  15834. */
  15835. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15836. /**
  15837. * Computes a new Color3 converted from the current one to gamma space
  15838. * @returns a new Color3 object
  15839. */
  15840. toGammaSpace(): Color3;
  15841. /**
  15842. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15843. * @param convertedColor defines the Color3 object where to store the gamma space version
  15844. * @returns the unmodified Color3
  15845. */
  15846. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15847. /**
  15848. * Creates a new Color3 from the string containing valid hexadecimal values
  15849. * @param hex defines a string containing valid hexadecimal values
  15850. * @returns a new Color3 object
  15851. */
  15852. static FromHexString(hex: string): Color3;
  15853. /**
  15854. * Creates a new Vector3 from the starting index of the given array
  15855. * @param array defines the source array
  15856. * @param offset defines an offset in the source array
  15857. * @returns a new Color3 object
  15858. */
  15859. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15860. /**
  15861. * Creates a new Color3 from integer values (< 256)
  15862. * @param r defines the red component to read from (value between 0 and 255)
  15863. * @param g defines the green component to read from (value between 0 and 255)
  15864. * @param b defines the blue component to read from (value between 0 and 255)
  15865. * @returns a new Color3 object
  15866. */
  15867. static FromInts(r: number, g: number, b: number): Color3;
  15868. /**
  15869. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15870. * @param start defines the start Color3 value
  15871. * @param end defines the end Color3 value
  15872. * @param amount defines the gradient value between start and end
  15873. * @returns a new Color3 object
  15874. */
  15875. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15876. /**
  15877. * Returns a Color3 value containing a red color
  15878. * @returns a new Color3 object
  15879. */
  15880. static Red(): Color3;
  15881. /**
  15882. * Returns a Color3 value containing a green color
  15883. * @returns a new Color3 object
  15884. */
  15885. static Green(): Color3;
  15886. /**
  15887. * Returns a Color3 value containing a blue color
  15888. * @returns a new Color3 object
  15889. */
  15890. static Blue(): Color3;
  15891. /**
  15892. * Returns a Color3 value containing a black color
  15893. * @returns a new Color3 object
  15894. */
  15895. static Black(): Color3;
  15896. /**
  15897. * Returns a Color3 value containing a white color
  15898. * @returns a new Color3 object
  15899. */
  15900. static White(): Color3;
  15901. /**
  15902. * Returns a Color3 value containing a purple color
  15903. * @returns a new Color3 object
  15904. */
  15905. static Purple(): Color3;
  15906. /**
  15907. * Returns a Color3 value containing a magenta color
  15908. * @returns a new Color3 object
  15909. */
  15910. static Magenta(): Color3;
  15911. /**
  15912. * Returns a Color3 value containing a yellow color
  15913. * @returns a new Color3 object
  15914. */
  15915. static Yellow(): Color3;
  15916. /**
  15917. * Returns a Color3 value containing a gray color
  15918. * @returns a new Color3 object
  15919. */
  15920. static Gray(): Color3;
  15921. /**
  15922. * Returns a Color3 value containing a teal color
  15923. * @returns a new Color3 object
  15924. */
  15925. static Teal(): Color3;
  15926. /**
  15927. * Returns a Color3 value containing a random color
  15928. * @returns a new Color3 object
  15929. */
  15930. static Random(): Color3;
  15931. }
  15932. /**
  15933. * Class used to hold a RBGA color
  15934. */
  15935. class Color4 {
  15936. /**
  15937. * Defines the red component (between 0 and 1, default is 0)
  15938. */
  15939. r: number;
  15940. /**
  15941. * Defines the green component (between 0 and 1, default is 0)
  15942. */
  15943. g: number;
  15944. /**
  15945. * Defines the blue component (between 0 and 1, default is 0)
  15946. */
  15947. b: number;
  15948. /**
  15949. * Defines the alpha component (between 0 and 1, default is 1)
  15950. */
  15951. a: number;
  15952. /**
  15953. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15954. * @param r defines the red component (between 0 and 1, default is 0)
  15955. * @param g defines the green component (between 0 and 1, default is 0)
  15956. * @param b defines the blue component (between 0 and 1, default is 0)
  15957. * @param a defines the alpha component (between 0 and 1, default is 1)
  15958. */
  15959. constructor(
  15960. /**
  15961. * Defines the red component (between 0 and 1, default is 0)
  15962. */
  15963. r?: number,
  15964. /**
  15965. * Defines the green component (between 0 and 1, default is 0)
  15966. */
  15967. g?: number,
  15968. /**
  15969. * Defines the blue component (between 0 and 1, default is 0)
  15970. */
  15971. b?: number,
  15972. /**
  15973. * Defines the alpha component (between 0 and 1, default is 1)
  15974. */
  15975. a?: number);
  15976. /**
  15977. * Adds in place the given Color4 values to the current Color4 object
  15978. * @param right defines the second operand
  15979. * @returns the current updated Color4 object
  15980. */
  15981. addInPlace(right: Color4): Color4;
  15982. /**
  15983. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15984. * @returns the new array
  15985. */
  15986. asArray(): number[];
  15987. /**
  15988. * Stores from the starting index in the given array the Color4 successive values
  15989. * @param array defines the array where to store the r,g,b components
  15990. * @param index defines an optional index in the target array to define where to start storing values
  15991. * @returns the current Color4 object
  15992. */
  15993. toArray(array: number[], index?: number): Color4;
  15994. /**
  15995. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15996. * @param right defines the second operand
  15997. * @returns a new Color4 object
  15998. */
  15999. add(right: Color4): Color4;
  16000. /**
  16001. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  16002. * @param right defines the second operand
  16003. * @returns a new Color4 object
  16004. */
  16005. subtract(right: Color4): Color4;
  16006. /**
  16007. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  16008. * @param right defines the second operand
  16009. * @param result defines the Color4 object where to store the result
  16010. * @returns the current Color4 object
  16011. */
  16012. subtractToRef(right: Color4, result: Color4): Color4;
  16013. /**
  16014. * Creates a new Color4 with the current Color4 values multiplied by scale
  16015. * @param scale defines the scaling factor to apply
  16016. * @returns a new Color4 object
  16017. */
  16018. scale(scale: number): Color4;
  16019. /**
  16020. * Multiplies the current Color4 values by scale and stores the result in "result"
  16021. * @param scale defines the scaling factor to apply
  16022. * @param result defines the Color4 object where to store the result
  16023. * @returns the current unmodified Color4
  16024. */
  16025. scaleToRef(scale: number, result: Color4): Color4;
  16026. /**
  16027. * Scale the current Color4 values by a factor and add the result to a given Color4
  16028. * @param scale defines the scale factor
  16029. * @param result defines the Color4 object where to store the result
  16030. * @returns the unmodified current Color4
  16031. */
  16032. scaleAndAddToRef(scale: number, result: Color4): Color4;
  16033. /**
  16034. * Clamps the rgb values by the min and max values and stores the result into "result"
  16035. * @param min defines minimum clamping value (default is 0)
  16036. * @param max defines maximum clamping value (default is 1)
  16037. * @param result defines color to store the result into.
  16038. * @returns the cuurent Color4
  16039. */
  16040. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  16041. /**
  16042. * Multipy an Color4 value by another and return a new Color4 object
  16043. * @param color defines the Color4 value to multiply by
  16044. * @returns a new Color4 object
  16045. */
  16046. multiply(color: Color4): Color4;
  16047. /**
  16048. * Multipy a Color4 value by another and push the result in a reference value
  16049. * @param color defines the Color4 value to multiply by
  16050. * @param result defines the Color4 to fill the result in
  16051. * @returns the result Color4
  16052. */
  16053. multiplyToRef(color: Color4, result: Color4): Color4;
  16054. /**
  16055. * Creates a string with the Color4 current values
  16056. * @returns the string representation of the Color4 object
  16057. */
  16058. toString(): string;
  16059. /**
  16060. * Returns the string "Color4"
  16061. * @returns "Color4"
  16062. */
  16063. getClassName(): string;
  16064. /**
  16065. * Compute the Color4 hash code
  16066. * @returns an unique number that can be used to hash Color4 objects
  16067. */
  16068. getHashCode(): number;
  16069. /**
  16070. * Creates a new Color4 copied from the current one
  16071. * @returns a new Color4 object
  16072. */
  16073. clone(): Color4;
  16074. /**
  16075. * Copies the given Color4 values into the current one
  16076. * @param source defines the source Color4 object
  16077. * @returns the current updated Color4 object
  16078. */
  16079. copyFrom(source: Color4): Color4;
  16080. /**
  16081. * Copies the given float values into the current one
  16082. * @param r defines the red component to read from
  16083. * @param g defines the green component to read from
  16084. * @param b defines the blue component to read from
  16085. * @param a defines the alpha component to read from
  16086. * @returns the current updated Color4 object
  16087. */
  16088. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  16089. /**
  16090. * Copies the given float values into the current one
  16091. * @param r defines the red component to read from
  16092. * @param g defines the green component to read from
  16093. * @param b defines the blue component to read from
  16094. * @param a defines the alpha component to read from
  16095. * @returns the current updated Color4 object
  16096. */
  16097. set(r: number, g: number, b: number, a: number): Color4;
  16098. /**
  16099. * Compute the Color4 hexadecimal code as a string
  16100. * @returns a string containing the hexadecimal representation of the Color4 object
  16101. */
  16102. toHexString(): string;
  16103. /**
  16104. * Computes a new Color4 converted from the current one to linear space
  16105. * @returns a new Color4 object
  16106. */
  16107. toLinearSpace(): Color4;
  16108. /**
  16109. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  16110. * @param convertedColor defines the Color4 object where to store the linear space version
  16111. * @returns the unmodified Color4
  16112. */
  16113. toLinearSpaceToRef(convertedColor: Color4): Color4;
  16114. /**
  16115. * Computes a new Color4 converted from the current one to gamma space
  16116. * @returns a new Color4 object
  16117. */
  16118. toGammaSpace(): Color4;
  16119. /**
  16120. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  16121. * @param convertedColor defines the Color4 object where to store the gamma space version
  16122. * @returns the unmodified Color4
  16123. */
  16124. toGammaSpaceToRef(convertedColor: Color4): Color4;
  16125. /**
  16126. * Creates a new Color4 from the string containing valid hexadecimal values
  16127. * @param hex defines a string containing valid hexadecimal values
  16128. * @returns a new Color4 object
  16129. */
  16130. static FromHexString(hex: string): Color4;
  16131. /**
  16132. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16133. * @param left defines the start value
  16134. * @param right defines the end value
  16135. * @param amount defines the gradient factor
  16136. * @returns a new Color4 object
  16137. */
  16138. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  16139. /**
  16140. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16141. * @param left defines the start value
  16142. * @param right defines the end value
  16143. * @param amount defines the gradient factor
  16144. * @param result defines the Color4 object where to store data
  16145. */
  16146. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  16147. /**
  16148. * Creates a new Color4 from the starting index element of the given array
  16149. * @param array defines the source array to read from
  16150. * @param offset defines the offset in the source array
  16151. * @returns a new Color4 object
  16152. */
  16153. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  16154. /**
  16155. * Creates a new Color3 from integer values (< 256)
  16156. * @param r defines the red component to read from (value between 0 and 255)
  16157. * @param g defines the green component to read from (value between 0 and 255)
  16158. * @param b defines the blue component to read from (value between 0 and 255)
  16159. * @param a defines the alpha component to read from (value between 0 and 255)
  16160. * @returns a new Color3 object
  16161. */
  16162. static FromInts(r: number, g: number, b: number, a: number): Color4;
  16163. /**
  16164. * Check the content of a given array and convert it to an array containing RGBA data
  16165. * If the original array was already containing count * 4 values then it is returned directly
  16166. * @param colors defines the array to check
  16167. * @param count defines the number of RGBA data to expect
  16168. * @returns an array containing count * 4 values (RGBA)
  16169. */
  16170. static CheckColors4(colors: number[], count: number): number[];
  16171. }
  16172. /**
  16173. * Class representing a vector containing 2 coordinates
  16174. */
  16175. class Vector2 {
  16176. /** defines the first coordinate */
  16177. x: number;
  16178. /** defines the second coordinate */
  16179. y: number;
  16180. /**
  16181. * Creates a new Vector2 from the given x and y coordinates
  16182. * @param x defines the first coordinate
  16183. * @param y defines the second coordinate
  16184. */
  16185. constructor(
  16186. /** defines the first coordinate */
  16187. x?: number,
  16188. /** defines the second coordinate */
  16189. y?: number);
  16190. /**
  16191. * Gets a string with the Vector2 coordinates
  16192. * @returns a string with the Vector2 coordinates
  16193. */
  16194. toString(): string;
  16195. /**
  16196. * Gets class name
  16197. * @returns the string "Vector2"
  16198. */
  16199. getClassName(): string;
  16200. /**
  16201. * Gets current vector hash code
  16202. * @returns the Vector2 hash code as a number
  16203. */
  16204. getHashCode(): number;
  16205. /**
  16206. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  16207. * @param array defines the source array
  16208. * @param index defines the offset in source array
  16209. * @returns the current Vector2
  16210. */
  16211. toArray(array: FloatArray, index?: number): Vector2;
  16212. /**
  16213. * Copy the current vector to an array
  16214. * @returns a new array with 2 elements: the Vector2 coordinates.
  16215. */
  16216. asArray(): number[];
  16217. /**
  16218. * Sets the Vector2 coordinates with the given Vector2 coordinates
  16219. * @param source defines the source Vector2
  16220. * @returns the current updated Vector2
  16221. */
  16222. copyFrom(source: Vector2): Vector2;
  16223. /**
  16224. * Sets the Vector2 coordinates with the given floats
  16225. * @param x defines the first coordinate
  16226. * @param y defines the second coordinate
  16227. * @returns the current updated Vector2
  16228. */
  16229. copyFromFloats(x: number, y: number): Vector2;
  16230. /**
  16231. * Sets the Vector2 coordinates with the given floats
  16232. * @param x defines the first coordinate
  16233. * @param y defines the second coordinate
  16234. * @returns the current updated Vector2
  16235. */
  16236. set(x: number, y: number): Vector2;
  16237. /**
  16238. * Add another vector with the current one
  16239. * @param otherVector defines the other vector
  16240. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16241. */
  16242. add(otherVector: Vector2): Vector2;
  16243. /**
  16244. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16245. * @param otherVector defines the other vector
  16246. * @param result defines the target vector
  16247. * @returns the unmodified current Vector2
  16248. */
  16249. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16250. /**
  16251. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16252. * @param otherVector defines the other vector
  16253. * @returns the current updated Vector2
  16254. */
  16255. addInPlace(otherVector: Vector2): Vector2;
  16256. /**
  16257. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16258. * @param otherVector defines the other vector
  16259. * @returns a new Vector2
  16260. */
  16261. addVector3(otherVector: Vector3): Vector2;
  16262. /**
  16263. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16264. * @param otherVector defines the other vector
  16265. * @returns a new Vector2
  16266. */
  16267. subtract(otherVector: Vector2): Vector2;
  16268. /**
  16269. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16270. * @param otherVector defines the other vector
  16271. * @param result defines the target vector
  16272. * @returns the unmodified current Vector2
  16273. */
  16274. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16275. /**
  16276. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16277. * @param otherVector defines the other vector
  16278. * @returns the current updated Vector2
  16279. */
  16280. subtractInPlace(otherVector: Vector2): Vector2;
  16281. /**
  16282. * Multiplies in place the current Vector2 coordinates by the given ones
  16283. * @param otherVector defines the other vector
  16284. * @returns the current updated Vector2
  16285. */
  16286. multiplyInPlace(otherVector: Vector2): Vector2;
  16287. /**
  16288. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16289. * @param otherVector defines the other vector
  16290. * @returns a new Vector2
  16291. */
  16292. multiply(otherVector: Vector2): Vector2;
  16293. /**
  16294. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16295. * @param otherVector defines the other vector
  16296. * @param result defines the target vector
  16297. * @returns the unmodified current Vector2
  16298. */
  16299. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16300. /**
  16301. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16302. * @param x defines the first coordinate
  16303. * @param y defines the second coordinate
  16304. * @returns a new Vector2
  16305. */
  16306. multiplyByFloats(x: number, y: number): Vector2;
  16307. /**
  16308. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16309. * @param otherVector defines the other vector
  16310. * @returns a new Vector2
  16311. */
  16312. divide(otherVector: Vector2): Vector2;
  16313. /**
  16314. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16315. * @param otherVector defines the other vector
  16316. * @param result defines the target vector
  16317. * @returns the unmodified current Vector2
  16318. */
  16319. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16320. /**
  16321. * Divides the current Vector2 coordinates by the given ones
  16322. * @param otherVector defines the other vector
  16323. * @returns the current updated Vector2
  16324. */
  16325. divideInPlace(otherVector: Vector2): Vector2;
  16326. /**
  16327. * Gets a new Vector2 with current Vector2 negated coordinates
  16328. * @returns a new Vector2
  16329. */
  16330. negate(): Vector2;
  16331. /**
  16332. * Multiply the Vector2 coordinates by scale
  16333. * @param scale defines the scaling factor
  16334. * @returns the current updated Vector2
  16335. */
  16336. scaleInPlace(scale: number): Vector2;
  16337. /**
  16338. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16339. * @param scale defines the scaling factor
  16340. * @returns a new Vector2
  16341. */
  16342. scale(scale: number): Vector2;
  16343. /**
  16344. * Scale the current Vector2 values by a factor to a given Vector2
  16345. * @param scale defines the scale factor
  16346. * @param result defines the Vector2 object where to store the result
  16347. * @returns the unmodified current Vector2
  16348. */
  16349. scaleToRef(scale: number, result: Vector2): Vector2;
  16350. /**
  16351. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16352. * @param scale defines the scale factor
  16353. * @param result defines the Vector2 object where to store the result
  16354. * @returns the unmodified current Vector2
  16355. */
  16356. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16357. /**
  16358. * Gets a boolean if two vectors are equals
  16359. * @param otherVector defines the other vector
  16360. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16361. */
  16362. equals(otherVector: Vector2): boolean;
  16363. /**
  16364. * Gets a boolean if two vectors are equals (using an epsilon value)
  16365. * @param otherVector defines the other vector
  16366. * @param epsilon defines the minimal distance to consider equality
  16367. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16368. */
  16369. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16370. /**
  16371. * Gets a new Vector2 from current Vector2 floored values
  16372. * @returns a new Vector2
  16373. */
  16374. floor(): Vector2;
  16375. /**
  16376. * Gets a new Vector2 from current Vector2 floored values
  16377. * @returns a new Vector2
  16378. */
  16379. fract(): Vector2;
  16380. /**
  16381. * Gets the length of the vector
  16382. * @returns the vector length (float)
  16383. */
  16384. length(): number;
  16385. /**
  16386. * Gets the vector squared length
  16387. * @returns the vector squared length (float)
  16388. */
  16389. lengthSquared(): number;
  16390. /**
  16391. * Normalize the vector
  16392. * @returns the current updated Vector2
  16393. */
  16394. normalize(): Vector2;
  16395. /**
  16396. * Gets a new Vector2 copied from the Vector2
  16397. * @returns a new Vector2
  16398. */
  16399. clone(): Vector2;
  16400. /**
  16401. * Gets a new Vector2(0, 0)
  16402. * @returns a new Vector2
  16403. */
  16404. static Zero(): Vector2;
  16405. /**
  16406. * Gets a new Vector2(1, 1)
  16407. * @returns a new Vector2
  16408. */
  16409. static One(): Vector2;
  16410. /**
  16411. * Gets a new Vector2 set from the given index element of the given array
  16412. * @param array defines the data source
  16413. * @param offset defines the offset in the data source
  16414. * @returns a new Vector2
  16415. */
  16416. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16417. /**
  16418. * Sets "result" from the given index element of the given array
  16419. * @param array defines the data source
  16420. * @param offset defines the offset in the data source
  16421. * @param result defines the target vector
  16422. */
  16423. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16424. /**
  16425. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16426. * @param value1 defines 1st point of control
  16427. * @param value2 defines 2nd point of control
  16428. * @param value3 defines 3rd point of control
  16429. * @param value4 defines 4th point of control
  16430. * @param amount defines the interpolation factor
  16431. * @returns a new Vector2
  16432. */
  16433. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16434. /**
  16435. * 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".
  16436. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16437. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16438. * @param value defines the value to clamp
  16439. * @param min defines the lower limit
  16440. * @param max defines the upper limit
  16441. * @returns a new Vector2
  16442. */
  16443. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16444. /**
  16445. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16446. * @param value1 defines the 1st control point
  16447. * @param tangent1 defines the outgoing tangent
  16448. * @param value2 defines the 2nd control point
  16449. * @param tangent2 defines the incoming tangent
  16450. * @param amount defines the interpolation factor
  16451. * @returns a new Vector2
  16452. */
  16453. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16454. /**
  16455. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16456. * @param start defines the start vector
  16457. * @param end defines the end vector
  16458. * @param amount defines the interpolation factor
  16459. * @returns a new Vector2
  16460. */
  16461. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16462. /**
  16463. * Gets the dot product of the vector "left" and the vector "right"
  16464. * @param left defines first vector
  16465. * @param right defines second vector
  16466. * @returns the dot product (float)
  16467. */
  16468. static Dot(left: Vector2, right: Vector2): number;
  16469. /**
  16470. * Returns a new Vector2 equal to the normalized given vector
  16471. * @param vector defines the vector to normalize
  16472. * @returns a new Vector2
  16473. */
  16474. static Normalize(vector: Vector2): Vector2;
  16475. /**
  16476. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16477. * @param left defines 1st vector
  16478. * @param right defines 2nd vector
  16479. * @returns a new Vector2
  16480. */
  16481. static Minimize(left: Vector2, right: Vector2): Vector2;
  16482. /**
  16483. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16484. * @param left defines 1st vector
  16485. * @param right defines 2nd vector
  16486. * @returns a new Vector2
  16487. */
  16488. static Maximize(left: Vector2, right: Vector2): Vector2;
  16489. /**
  16490. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16491. * @param vector defines the vector to transform
  16492. * @param transformation defines the matrix to apply
  16493. * @returns a new Vector2
  16494. */
  16495. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16496. /**
  16497. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16498. * @param vector defines the vector to transform
  16499. * @param transformation defines the matrix to apply
  16500. * @param result defines the target vector
  16501. */
  16502. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16503. /**
  16504. * Determines if a given vector is included in a triangle
  16505. * @param p defines the vector to test
  16506. * @param p0 defines 1st triangle point
  16507. * @param p1 defines 2nd triangle point
  16508. * @param p2 defines 3rd triangle point
  16509. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16510. */
  16511. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16512. /**
  16513. * Gets the distance between the vectors "value1" and "value2"
  16514. * @param value1 defines first vector
  16515. * @param value2 defines second vector
  16516. * @returns the distance between vectors
  16517. */
  16518. static Distance(value1: Vector2, value2: Vector2): number;
  16519. /**
  16520. * Returns the squared distance between the vectors "value1" and "value2"
  16521. * @param value1 defines first vector
  16522. * @param value2 defines second vector
  16523. * @returns the squared distance between vectors
  16524. */
  16525. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16526. /**
  16527. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16528. * @param value1 defines first vector
  16529. * @param value2 defines second vector
  16530. * @returns a new Vector2
  16531. */
  16532. static Center(value1: Vector2, value2: Vector2): Vector2;
  16533. /**
  16534. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16535. * @param p defines the middle point
  16536. * @param segA defines one point of the segment
  16537. * @param segB defines the other point of the segment
  16538. * @returns the shortest distance
  16539. */
  16540. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16541. }
  16542. /**
  16543. * Classed used to store (x,y,z) vector representation
  16544. * A Vector3 is the main object used in 3D geometry
  16545. * It can represent etiher the coordinates of a point the space, either a direction
  16546. * Reminder: Babylon.js uses a left handed forward facing system
  16547. */
  16548. class Vector3 {
  16549. /**
  16550. * Defines the first coordinates (on X axis)
  16551. */
  16552. x: number;
  16553. /**
  16554. * Defines the second coordinates (on Y axis)
  16555. */
  16556. y: number;
  16557. /**
  16558. * Defines the third coordinates (on Z axis)
  16559. */
  16560. z: number;
  16561. /**
  16562. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16563. * @param x defines the first coordinates (on X axis)
  16564. * @param y defines the second coordinates (on Y axis)
  16565. * @param z defines the third coordinates (on Z axis)
  16566. */
  16567. constructor(
  16568. /**
  16569. * Defines the first coordinates (on X axis)
  16570. */
  16571. x?: number,
  16572. /**
  16573. * Defines the second coordinates (on Y axis)
  16574. */
  16575. y?: number,
  16576. /**
  16577. * Defines the third coordinates (on Z axis)
  16578. */
  16579. z?: number);
  16580. /**
  16581. * Creates a string representation of the Vector3
  16582. * @returns a string with the Vector3 coordinates.
  16583. */
  16584. toString(): string;
  16585. /**
  16586. * Gets the class name
  16587. * @returns the string "Vector3"
  16588. */
  16589. getClassName(): string;
  16590. /**
  16591. * Creates the Vector3 hash code
  16592. * @returns a number which tends to be unique between Vector3 instances
  16593. */
  16594. getHashCode(): number;
  16595. /**
  16596. * Creates an array containing three elements : the coordinates of the Vector3
  16597. * @returns a new array of numbers
  16598. */
  16599. asArray(): number[];
  16600. /**
  16601. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16602. * @param array defines the destination array
  16603. * @param index defines the offset in the destination array
  16604. * @returns the current Vector3
  16605. */
  16606. toArray(array: FloatArray, index?: number): Vector3;
  16607. /**
  16608. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16609. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16610. */
  16611. toQuaternion(): Quaternion;
  16612. /**
  16613. * Adds the given vector to the current Vector3
  16614. * @param otherVector defines the second operand
  16615. * @returns the current updated Vector3
  16616. */
  16617. addInPlace(otherVector: Vector3): Vector3;
  16618. /**
  16619. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16620. * @param otherVector defines the second operand
  16621. * @returns the resulting Vector3
  16622. */
  16623. add(otherVector: Vector3): Vector3;
  16624. /**
  16625. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16626. * @param otherVector defines the second operand
  16627. * @param result defines the Vector3 object where to store the result
  16628. * @returns the current Vector3
  16629. */
  16630. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16631. /**
  16632. * Subtract the given vector from the current Vector3
  16633. * @param otherVector defines the second operand
  16634. * @returns the current updated Vector3
  16635. */
  16636. subtractInPlace(otherVector: Vector3): Vector3;
  16637. /**
  16638. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16639. * @param otherVector defines the second operand
  16640. * @returns the resulting Vector3
  16641. */
  16642. subtract(otherVector: Vector3): Vector3;
  16643. /**
  16644. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16645. * @param otherVector defines the second operand
  16646. * @param result defines the Vector3 object where to store the result
  16647. * @returns the current Vector3
  16648. */
  16649. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16650. /**
  16651. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16652. * @param x defines the x coordinate of the operand
  16653. * @param y defines the y coordinate of the operand
  16654. * @param z defines the z coordinate of the operand
  16655. * @returns the resulting Vector3
  16656. */
  16657. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16658. /**
  16659. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16660. * @param x defines the x coordinate of the operand
  16661. * @param y defines the y coordinate of the operand
  16662. * @param z defines the z coordinate of the operand
  16663. * @param result defines the Vector3 object where to store the result
  16664. * @returns the current Vector3
  16665. */
  16666. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16667. /**
  16668. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16669. * @returns a new Vector3
  16670. */
  16671. negate(): Vector3;
  16672. /**
  16673. * Multiplies the Vector3 coordinates by the float "scale"
  16674. * @param scale defines the multiplier factor
  16675. * @returns the current updated Vector3
  16676. */
  16677. scaleInPlace(scale: number): Vector3;
  16678. /**
  16679. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16680. * @param scale defines the multiplier factor
  16681. * @returns a new Vector3
  16682. */
  16683. scale(scale: number): Vector3;
  16684. /**
  16685. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16686. * @param scale defines the multiplier factor
  16687. * @param result defines the Vector3 object where to store the result
  16688. * @returns the current Vector3
  16689. */
  16690. scaleToRef(scale: number, result: Vector3): Vector3;
  16691. /**
  16692. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16693. * @param scale defines the scale factor
  16694. * @param result defines the Vector3 object where to store the result
  16695. * @returns the unmodified current Vector3
  16696. */
  16697. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16698. /**
  16699. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16700. * @param otherVector defines the second operand
  16701. * @returns true if both vectors are equals
  16702. */
  16703. equals(otherVector: Vector3): boolean;
  16704. /**
  16705. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16706. * @param otherVector defines the second operand
  16707. * @param epsilon defines the minimal distance to define values as equals
  16708. * @returns true if both vectors are distant less than epsilon
  16709. */
  16710. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16711. /**
  16712. * Returns true if the current Vector3 coordinates equals the given floats
  16713. * @param x defines the x coordinate of the operand
  16714. * @param y defines the y coordinate of the operand
  16715. * @param z defines the z coordinate of the operand
  16716. * @returns true if both vectors are equals
  16717. */
  16718. equalsToFloats(x: number, y: number, z: number): boolean;
  16719. /**
  16720. * Multiplies the current Vector3 coordinates by the given ones
  16721. * @param otherVector defines the second operand
  16722. * @returns the current updated Vector3
  16723. */
  16724. multiplyInPlace(otherVector: Vector3): Vector3;
  16725. /**
  16726. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16727. * @param otherVector defines the second operand
  16728. * @returns the new Vector3
  16729. */
  16730. multiply(otherVector: Vector3): Vector3;
  16731. /**
  16732. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16733. * @param otherVector defines the second operand
  16734. * @param result defines the Vector3 object where to store the result
  16735. * @returns the current Vector3
  16736. */
  16737. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16738. /**
  16739. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16740. * @param x defines the x coordinate of the operand
  16741. * @param y defines the y coordinate of the operand
  16742. * @param z defines the z coordinate of the operand
  16743. * @returns the new Vector3
  16744. */
  16745. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16746. /**
  16747. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16748. * @param otherVector defines the second operand
  16749. * @returns the new Vector3
  16750. */
  16751. divide(otherVector: Vector3): Vector3;
  16752. /**
  16753. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16754. * @param otherVector defines the second operand
  16755. * @param result defines the Vector3 object where to store the result
  16756. * @returns the current Vector3
  16757. */
  16758. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16759. /**
  16760. * Divides the current Vector3 coordinates by the given ones.
  16761. * @param otherVector defines the second operand
  16762. * @returns the current updated Vector3
  16763. */
  16764. divideInPlace(otherVector: Vector3): Vector3;
  16765. /**
  16766. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16767. * @param other defines the second operand
  16768. * @returns the current updated Vector3
  16769. */
  16770. minimizeInPlace(other: Vector3): Vector3;
  16771. /**
  16772. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16773. * @param other defines the second operand
  16774. * @returns the current updated Vector3
  16775. */
  16776. maximizeInPlace(other: Vector3): Vector3;
  16777. /**
  16778. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16779. */
  16780. readonly isNonUniform: boolean;
  16781. /**
  16782. * Gets a new Vector3 from current Vector3 floored values
  16783. * @returns a new Vector3
  16784. */
  16785. floor(): Vector3;
  16786. /**
  16787. * Gets a new Vector3 from current Vector3 floored values
  16788. * @returns a new Vector3
  16789. */
  16790. fract(): Vector3;
  16791. /**
  16792. * Gets the length of the Vector3
  16793. * @returns the length of the Vecto3
  16794. */
  16795. length(): number;
  16796. /**
  16797. * Gets the squared length of the Vector3
  16798. * @returns squared length of the Vector3
  16799. */
  16800. lengthSquared(): number;
  16801. /**
  16802. * Normalize the current Vector3.
  16803. * Please note that this is an in place operation.
  16804. * @returns the current updated Vector3
  16805. */
  16806. normalize(): Vector3;
  16807. /**
  16808. * Normalize the current Vector3 to a new vector
  16809. * @returns the new Vector3
  16810. */
  16811. normalizeToNew(): Vector3;
  16812. /**
  16813. * Normalize the current Vector3 to the reference
  16814. * @param reference define the Vector3 to update
  16815. * @returns the updated Vector3
  16816. */
  16817. normalizeToRef(reference: Vector3): Vector3;
  16818. /**
  16819. * Creates a new Vector3 copied from the current Vector3
  16820. * @returns the new Vector3
  16821. */
  16822. clone(): Vector3;
  16823. /**
  16824. * Copies the given vector coordinates to the current Vector3 ones
  16825. * @param source defines the source Vector3
  16826. * @returns the current updated Vector3
  16827. */
  16828. copyFrom(source: Vector3): Vector3;
  16829. /**
  16830. * Copies the given floats to the current Vector3 coordinates
  16831. * @param x defines the x coordinate of the operand
  16832. * @param y defines the y coordinate of the operand
  16833. * @param z defines the z coordinate of the operand
  16834. * @returns the current updated Vector3
  16835. */
  16836. copyFromFloats(x: number, y: number, z: number): Vector3;
  16837. /**
  16838. * Copies the given floats to the current Vector3 coordinates
  16839. * @param x defines the x coordinate of the operand
  16840. * @param y defines the y coordinate of the operand
  16841. * @param z defines the z coordinate of the operand
  16842. * @returns the current updated Vector3
  16843. */
  16844. set(x: number, y: number, z: number): Vector3;
  16845. /**
  16846. * Get the clip factor between two vectors
  16847. * @param vector0 defines the first operand
  16848. * @param vector1 defines the second operand
  16849. * @param axis defines the axis to use
  16850. * @param size defines the size along the axis
  16851. * @returns the clip factor
  16852. */
  16853. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16854. /**
  16855. * Get angle between two vectors
  16856. * @param vector0 angle between vector0 and vector1
  16857. * @param vector1 angle between vector0 and vector1
  16858. * @param normal direction of the normal
  16859. * @return the angle between vector0 and vector1
  16860. */
  16861. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16862. /**
  16863. * Returns a new Vector3 set from the index "offset" of the given array
  16864. * @param array defines the source array
  16865. * @param offset defines the offset in the source array
  16866. * @returns the new Vector3
  16867. */
  16868. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16869. /**
  16870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16871. * This function is deprecated. Use FromArray instead
  16872. * @param array defines the source array
  16873. * @param offset defines the offset in the source array
  16874. * @returns the new Vector3
  16875. */
  16876. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16877. /**
  16878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16879. * @param array defines the source array
  16880. * @param offset defines the offset in the source array
  16881. * @param result defines the Vector3 where to store the result
  16882. */
  16883. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16884. /**
  16885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16886. * This function is deprecated. Use FromArrayToRef instead.
  16887. * @param array defines the source array
  16888. * @param offset defines the offset in the source array
  16889. * @param result defines the Vector3 where to store the result
  16890. */
  16891. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16892. /**
  16893. * Sets the given vector "result" with the given floats.
  16894. * @param x defines the x coordinate of the source
  16895. * @param y defines the y coordinate of the source
  16896. * @param z defines the z coordinate of the source
  16897. * @param result defines the Vector3 where to store the result
  16898. */
  16899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16900. /**
  16901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16902. * @returns a new empty Vector3
  16903. */
  16904. static Zero(): Vector3;
  16905. /**
  16906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16907. * @returns a new unit Vector3
  16908. */
  16909. static One(): Vector3;
  16910. /**
  16911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16912. * @returns a new up Vector3
  16913. */
  16914. static Up(): Vector3;
  16915. /**
  16916. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16917. * @returns a new down Vector3
  16918. */
  16919. static Down(): Vector3;
  16920. /**
  16921. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16922. * @returns a new forward Vector3
  16923. */
  16924. static Forward(): Vector3;
  16925. /**
  16926. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16927. * @returns a new right Vector3
  16928. */
  16929. static Right(): Vector3;
  16930. /**
  16931. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16932. * @returns a new left Vector3
  16933. */
  16934. static Left(): Vector3;
  16935. /**
  16936. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16937. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16938. * @param vector defines the Vector3 to transform
  16939. * @param transformation defines the transformation matrix
  16940. * @returns the transformed Vector3
  16941. */
  16942. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16943. /**
  16944. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16945. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16946. * @param vector defines the Vector3 to transform
  16947. * @param transformation defines the transformation matrix
  16948. * @param result defines the Vector3 where to store the result
  16949. */
  16950. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16951. /**
  16952. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16953. * This method computes tranformed coordinates only, not transformed direction vectors
  16954. * @param x define the x coordinate of the source vector
  16955. * @param y define the y coordinate of the source vector
  16956. * @param z define the z coordinate of the source vector
  16957. * @param transformation defines the transformation matrix
  16958. * @param result defines the Vector3 where to store the result
  16959. */
  16960. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16961. /**
  16962. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16963. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16964. * @param vector defines the Vector3 to transform
  16965. * @param transformation defines the transformation matrix
  16966. * @returns the new Vector3
  16967. */
  16968. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16969. /**
  16970. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16971. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16972. * @param vector defines the Vector3 to transform
  16973. * @param transformation defines the transformation matrix
  16974. * @param result defines the Vector3 where to store the result
  16975. */
  16976. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16977. /**
  16978. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16979. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16980. * @param x define the x coordinate of the source vector
  16981. * @param y define the y coordinate of the source vector
  16982. * @param z define the z coordinate of the source vector
  16983. * @param transformation defines the transformation matrix
  16984. * @param result defines the Vector3 where to store the result
  16985. */
  16986. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16987. /**
  16988. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16989. * @param value1 defines the first control point
  16990. * @param value2 defines the second control point
  16991. * @param value3 defines the third control point
  16992. * @param value4 defines the fourth control point
  16993. * @param amount defines the amount on the spline to use
  16994. * @returns the new Vector3
  16995. */
  16996. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16997. /**
  16998. * 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"
  16999. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  17000. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  17001. * @param value defines the current value
  17002. * @param min defines the lower range value
  17003. * @param max defines the upper range value
  17004. * @returns the new Vector3
  17005. */
  17006. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  17007. /**
  17008. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  17009. * @param value1 defines the first control point
  17010. * @param tangent1 defines the first tangent vector
  17011. * @param value2 defines the second control point
  17012. * @param tangent2 defines the second tangent vector
  17013. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  17014. * @returns the new Vector3
  17015. */
  17016. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  17017. /**
  17018. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  17019. * @param start defines the start value
  17020. * @param end defines the end value
  17021. * @param amount max defines amount between both (between 0 and 1)
  17022. * @returns the new Vector3
  17023. */
  17024. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  17025. /**
  17026. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  17027. * @param start defines the start value
  17028. * @param end defines the end value
  17029. * @param amount max defines amount between both (between 0 and 1)
  17030. * @param result defines the Vector3 where to store the result
  17031. */
  17032. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  17033. /**
  17034. * Returns the dot product (float) between the vectors "left" and "right"
  17035. * @param left defines the left operand
  17036. * @param right defines the right operand
  17037. * @returns the dot product
  17038. */
  17039. static Dot(left: Vector3, right: Vector3): number;
  17040. /**
  17041. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  17042. * The cross product is then orthogonal to both "left" and "right"
  17043. * @param left defines the left operand
  17044. * @param right defines the right operand
  17045. * @returns the cross product
  17046. */
  17047. static Cross(left: Vector3, right: Vector3): Vector3;
  17048. /**
  17049. * Sets the given vector "result" with the cross product of "left" and "right"
  17050. * The cross product is then orthogonal to both "left" and "right"
  17051. * @param left defines the left operand
  17052. * @param right defines the right operand
  17053. * @param result defines the Vector3 where to store the result
  17054. */
  17055. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  17056. /**
  17057. * Returns a new Vector3 as the normalization of the given vector
  17058. * @param vector defines the Vector3 to normalize
  17059. * @returns the new Vector3
  17060. */
  17061. static Normalize(vector: Vector3): Vector3;
  17062. /**
  17063. * Sets the given vector "result" with the normalization of the given first vector
  17064. * @param vector defines the Vector3 to normalize
  17065. * @param result defines the Vector3 where to store the result
  17066. */
  17067. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  17068. private static _viewportMatrixCache;
  17069. /**
  17070. * Project a Vector3 onto screen space
  17071. * @param vector defines the Vector3 to project
  17072. * @param world defines the world matrix to use
  17073. * @param transform defines the transform (view x projection) matrix to use
  17074. * @param viewport defines the screen viewport to use
  17075. * @returns the new Vector3
  17076. */
  17077. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  17078. /**
  17079. * Unproject from screen space to object space
  17080. * @param source defines the screen space Vector3 to use
  17081. * @param viewportWidth defines the current width of the viewport
  17082. * @param viewportHeight defines the current height of the viewport
  17083. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17084. * @param transform defines the transform (view x projection) matrix to use
  17085. * @returns the new Vector3
  17086. */
  17087. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  17088. /**
  17089. * Unproject from screen space to object space
  17090. * @param source defines the screen space Vector3 to use
  17091. * @param viewportWidth defines the current width of the viewport
  17092. * @param viewportHeight defines the current height of the viewport
  17093. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17094. * @param view defines the view matrix to use
  17095. * @param projection defines the projection matrix to use
  17096. * @returns the new Vector3
  17097. */
  17098. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  17099. /**
  17100. * Unproject from screen space to object space
  17101. * @param source defines the screen space Vector3 to use
  17102. * @param viewportWidth defines the current width of the viewport
  17103. * @param viewportHeight defines the current height of the viewport
  17104. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17105. * @param view defines the view matrix to use
  17106. * @param projection defines the projection matrix to use
  17107. * @param result defines the Vector3 where to store the result
  17108. */
  17109. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17110. /**
  17111. * Unproject from screen space to object space
  17112. * @param sourceX defines the screen space x coordinate to use
  17113. * @param sourceY defines the screen space y coordinate to use
  17114. * @param sourceZ defines the screen space z coordinate to use
  17115. * @param viewportWidth defines the current width of the viewport
  17116. * @param viewportHeight defines the current height of the viewport
  17117. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17118. * @param view defines the view matrix to use
  17119. * @param projection defines the projection matrix to use
  17120. * @param result defines the Vector3 where to store the result
  17121. */
  17122. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17123. /**
  17124. * Gets the minimal coordinate values between two Vector3
  17125. * @param left defines the first operand
  17126. * @param right defines the second operand
  17127. * @returns the new Vector3
  17128. */
  17129. static Minimize(left: Vector3, right: Vector3): Vector3;
  17130. /**
  17131. * Gets the maximal coordinate values between two Vector3
  17132. * @param left defines the first operand
  17133. * @param right defines the second operand
  17134. * @returns the new Vector3
  17135. */
  17136. static Maximize(left: Vector3, right: Vector3): Vector3;
  17137. /**
  17138. * Returns the distance between the vectors "value1" and "value2"
  17139. * @param value1 defines the first operand
  17140. * @param value2 defines the second operand
  17141. * @returns the distance
  17142. */
  17143. static Distance(value1: Vector3, value2: Vector3): number;
  17144. /**
  17145. * Returns the squared distance between the vectors "value1" and "value2"
  17146. * @param value1 defines the first operand
  17147. * @param value2 defines the second operand
  17148. * @returns the squared distance
  17149. */
  17150. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  17151. /**
  17152. * Returns a new Vector3 located at the center between "value1" and "value2"
  17153. * @param value1 defines the first operand
  17154. * @param value2 defines the second operand
  17155. * @returns the new Vector3
  17156. */
  17157. static Center(value1: Vector3, value2: Vector3): Vector3;
  17158. /**
  17159. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  17160. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  17161. * to something in order to rotate it from its local system to the given target system
  17162. * Note: axis1, axis2 and axis3 are normalized during this operation
  17163. * @param axis1 defines the first axis
  17164. * @param axis2 defines the second axis
  17165. * @param axis3 defines the third axis
  17166. * @returns a new Vector3
  17167. */
  17168. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  17169. /**
  17170. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  17171. * @param axis1 defines the first axis
  17172. * @param axis2 defines the second axis
  17173. * @param axis3 defines the third axis
  17174. * @param ref defines the Vector3 where to store the result
  17175. */
  17176. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  17177. }
  17178. class Vector4 {
  17179. x: number;
  17180. y: number;
  17181. z: number;
  17182. w: number;
  17183. /**
  17184. * Creates a Vector4 object from the given floats.
  17185. */
  17186. constructor(x: number, y: number, z: number, w: number);
  17187. /**
  17188. * Returns the string with the Vector4 coordinates.
  17189. */
  17190. toString(): string;
  17191. /**
  17192. * Returns the string "Vector4".
  17193. */
  17194. getClassName(): string;
  17195. /**
  17196. * Returns the Vector4 hash code.
  17197. */
  17198. getHashCode(): number;
  17199. /**
  17200. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  17201. */
  17202. asArray(): number[];
  17203. /**
  17204. * Populates the given array from the given index with the Vector4 coordinates.
  17205. * Returns the Vector4.
  17206. */
  17207. toArray(array: FloatArray, index?: number): Vector4;
  17208. /**
  17209. * Adds the given vector to the current Vector4.
  17210. * Returns the updated Vector4.
  17211. */
  17212. addInPlace(otherVector: Vector4): Vector4;
  17213. /**
  17214. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  17215. */
  17216. add(otherVector: Vector4): Vector4;
  17217. /**
  17218. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  17219. * Returns the current Vector4.
  17220. */
  17221. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  17222. /**
  17223. * Subtract in place the given vector from the current Vector4.
  17224. * Returns the updated Vector4.
  17225. */
  17226. subtractInPlace(otherVector: Vector4): Vector4;
  17227. /**
  17228. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  17229. */
  17230. subtract(otherVector: Vector4): Vector4;
  17231. /**
  17232. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  17233. * Returns the current Vector4.
  17234. */
  17235. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  17236. /**
  17237. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17238. */
  17239. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17240. /**
  17241. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17242. * Returns the current Vector4.
  17243. */
  17244. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  17245. /**
  17246. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  17247. */
  17248. negate(): Vector4;
  17249. /**
  17250. * Multiplies the current Vector4 coordinates by scale (float).
  17251. * Returns the updated Vector4.
  17252. */
  17253. scaleInPlace(scale: number): Vector4;
  17254. /**
  17255. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  17256. */
  17257. scale(scale: number): Vector4;
  17258. /**
  17259. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17260. * Returns the current Vector4.
  17261. */
  17262. scaleToRef(scale: number, result: Vector4): Vector4;
  17263. /**
  17264. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17265. * @param scale defines the scale factor
  17266. * @param result defines the Vector4 object where to store the result
  17267. * @returns the unmodified current Vector4
  17268. */
  17269. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17270. /**
  17271. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17272. */
  17273. equals(otherVector: Vector4): boolean;
  17274. /**
  17275. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17276. */
  17277. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17278. /**
  17279. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17280. */
  17281. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17282. /**
  17283. * Multiplies in place the current Vector4 by the given one.
  17284. * Returns the updated Vector4.
  17285. */
  17286. multiplyInPlace(otherVector: Vector4): Vector4;
  17287. /**
  17288. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17289. */
  17290. multiply(otherVector: Vector4): Vector4;
  17291. /**
  17292. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17293. * Returns the current Vector4.
  17294. */
  17295. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17296. /**
  17297. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17298. */
  17299. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17300. /**
  17301. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17302. */
  17303. divide(otherVector: Vector4): Vector4;
  17304. /**
  17305. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17306. * Returns the current Vector4.
  17307. */
  17308. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17309. /**
  17310. * Divides the current Vector3 coordinates by the given ones.
  17311. * @returns the updated Vector3.
  17312. */
  17313. divideInPlace(otherVector: Vector4): Vector4;
  17314. /**
  17315. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17316. * @param other defines the second operand
  17317. * @returns the current updated Vector4
  17318. */
  17319. minimizeInPlace(other: Vector4): Vector4;
  17320. /**
  17321. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17322. * @param other defines the second operand
  17323. * @returns the current updated Vector4
  17324. */
  17325. maximizeInPlace(other: Vector4): Vector4;
  17326. /**
  17327. * Gets a new Vector4 from current Vector4 floored values
  17328. * @returns a new Vector4
  17329. */
  17330. floor(): Vector4;
  17331. /**
  17332. * Gets a new Vector4 from current Vector3 floored values
  17333. * @returns a new Vector4
  17334. */
  17335. fract(): Vector4;
  17336. /**
  17337. * Returns the Vector4 length (float).
  17338. */
  17339. length(): number;
  17340. /**
  17341. * Returns the Vector4 squared length (float).
  17342. */
  17343. lengthSquared(): number;
  17344. /**
  17345. * Normalizes in place the Vector4.
  17346. * Returns the updated Vector4.
  17347. */
  17348. normalize(): Vector4;
  17349. /**
  17350. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17351. */
  17352. toVector3(): Vector3;
  17353. /**
  17354. * Returns a new Vector4 copied from the current one.
  17355. */
  17356. clone(): Vector4;
  17357. /**
  17358. * Updates the current Vector4 with the given one coordinates.
  17359. * Returns the updated Vector4.
  17360. */
  17361. copyFrom(source: Vector4): Vector4;
  17362. /**
  17363. * Updates the current Vector4 coordinates with the given floats.
  17364. * Returns the updated Vector4.
  17365. */
  17366. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17367. /**
  17368. * Updates the current Vector4 coordinates with the given floats.
  17369. * Returns the updated Vector4.
  17370. */
  17371. set(x: number, y: number, z: number, w: number): Vector4;
  17372. /**
  17373. * Returns a new Vector4 set from the starting index of the given array.
  17374. */
  17375. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17376. /**
  17377. * Updates the given vector "result" from the starting index of the given array.
  17378. */
  17379. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17380. /**
  17381. * Updates the given vector "result" from the starting index of the given Float32Array.
  17382. */
  17383. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17384. /**
  17385. * Updates the given vector "result" coordinates from the given floats.
  17386. */
  17387. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17388. /**
  17389. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17390. */
  17391. static Zero(): Vector4;
  17392. /**
  17393. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17394. */
  17395. static One(): Vector4;
  17396. /**
  17397. * Returns a new normalized Vector4 from the given one.
  17398. */
  17399. static Normalize(vector: Vector4): Vector4;
  17400. /**
  17401. * Updates the given vector "result" from the normalization of the given one.
  17402. */
  17403. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17404. static Minimize(left: Vector4, right: Vector4): Vector4;
  17405. static Maximize(left: Vector4, right: Vector4): Vector4;
  17406. /**
  17407. * Returns the distance (float) between the vectors "value1" and "value2".
  17408. */
  17409. static Distance(value1: Vector4, value2: Vector4): number;
  17410. /**
  17411. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17412. */
  17413. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17414. /**
  17415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17416. */
  17417. static Center(value1: Vector4, value2: Vector4): Vector4;
  17418. /**
  17419. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17420. * This methods computes transformed normalized direction vectors only.
  17421. */
  17422. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17423. /**
  17424. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17425. * This methods computes transformed normalized direction vectors only.
  17426. */
  17427. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17428. /**
  17429. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17430. * This methods computes transformed normalized direction vectors only.
  17431. */
  17432. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17433. }
  17434. interface ISize {
  17435. width: number;
  17436. height: number;
  17437. }
  17438. class Size implements ISize {
  17439. width: number;
  17440. height: number;
  17441. /**
  17442. * Creates a Size object from the given width and height (floats).
  17443. */
  17444. constructor(width: number, height: number);
  17445. toString(): string;
  17446. /**
  17447. * Returns the string "Size"
  17448. */
  17449. getClassName(): string;
  17450. /**
  17451. * Returns the Size hash code.
  17452. */
  17453. getHashCode(): number;
  17454. /**
  17455. * Updates the current size from the given one.
  17456. * Returns the updated Size.
  17457. */
  17458. copyFrom(src: Size): void;
  17459. /**
  17460. * Updates in place the current Size from the given floats.
  17461. * Returns the updated Size.
  17462. */
  17463. copyFromFloats(width: number, height: number): Size;
  17464. /**
  17465. * Updates in place the current Size from the given floats.
  17466. * Returns the updated Size.
  17467. */
  17468. set(width: number, height: number): Size;
  17469. /**
  17470. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17471. */
  17472. multiplyByFloats(w: number, h: number): Size;
  17473. /**
  17474. * Returns a new Size copied from the given one.
  17475. */
  17476. clone(): Size;
  17477. /**
  17478. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17479. */
  17480. equals(other: Size): boolean;
  17481. /**
  17482. * Returns the surface of the Size : width * height (float).
  17483. */
  17484. readonly surface: number;
  17485. /**
  17486. * Returns a new Size set to (0.0, 0.0)
  17487. */
  17488. static Zero(): Size;
  17489. /**
  17490. * Returns a new Size set as the addition result of the current Size and the given one.
  17491. */
  17492. add(otherSize: Size): Size;
  17493. /**
  17494. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17495. */
  17496. subtract(otherSize: Size): Size;
  17497. /**
  17498. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17499. */
  17500. static Lerp(start: Size, end: Size, amount: number): Size;
  17501. }
  17502. /**
  17503. * Class used to store quaternion data
  17504. * @see https://en.wikipedia.org/wiki/Quaternion
  17505. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17506. */
  17507. class Quaternion {
  17508. /** defines the first component (0 by default) */
  17509. x: number;
  17510. /** defines the second component (0 by default) */
  17511. y: number;
  17512. /** defines the third component (0 by default) */
  17513. z: number;
  17514. /** defines the fourth component (1.0 by default) */
  17515. w: number;
  17516. /**
  17517. * Creates a new Quaternion from the given floats
  17518. * @param x defines the first component (0 by default)
  17519. * @param y defines the second component (0 by default)
  17520. * @param z defines the third component (0 by default)
  17521. * @param w defines the fourth component (1.0 by default)
  17522. */
  17523. constructor(
  17524. /** defines the first component (0 by default) */
  17525. x?: number,
  17526. /** defines the second component (0 by default) */
  17527. y?: number,
  17528. /** defines the third component (0 by default) */
  17529. z?: number,
  17530. /** defines the fourth component (1.0 by default) */
  17531. w?: number);
  17532. /**
  17533. * Gets a string representation for the current quaternion
  17534. * @returns a string with the Quaternion coordinates
  17535. */
  17536. toString(): string;
  17537. /**
  17538. * Gets the class name of the quaternion
  17539. * @returns the string "Quaternion"
  17540. */
  17541. getClassName(): string;
  17542. /**
  17543. * Gets a hash code for this quaternion
  17544. * @returns the quaternion hash code
  17545. */
  17546. getHashCode(): number;
  17547. /**
  17548. * Copy the quaternion to an array
  17549. * @returns a new array populated with 4 elements from the quaternion coordinates
  17550. */
  17551. asArray(): number[];
  17552. /**
  17553. * Check if two quaternions are equals
  17554. * @param otherQuaternion defines the second operand
  17555. * @return true if the current quaternion and the given one coordinates are strictly equals
  17556. */
  17557. equals(otherQuaternion: Quaternion): boolean;
  17558. /**
  17559. * Clone the current quaternion
  17560. * @returns a new quaternion copied from the current one
  17561. */
  17562. clone(): Quaternion;
  17563. /**
  17564. * Copy a quaternion to the current one
  17565. * @param other defines the other quaternion
  17566. * @returns the updated current quaternion
  17567. */
  17568. copyFrom(other: Quaternion): Quaternion;
  17569. /**
  17570. * Updates the current quaternion with the given float coordinates
  17571. * @param x defines the x coordinate
  17572. * @param y defines the y coordinate
  17573. * @param z defines the z coordinate
  17574. * @param w defines the w coordinate
  17575. * @returns the updated current quaternion
  17576. */
  17577. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17578. /**
  17579. * Updates the current quaternion from the given float coordinates
  17580. * @param x defines the x coordinate
  17581. * @param y defines the y coordinate
  17582. * @param z defines the z coordinate
  17583. * @param w defines the w coordinate
  17584. * @returns the updated current quaternion
  17585. */
  17586. set(x: number, y: number, z: number, w: number): Quaternion;
  17587. /**
  17588. * Adds two quaternions
  17589. * @param other defines the second operand
  17590. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17591. */
  17592. add(other: Quaternion): Quaternion;
  17593. /**
  17594. * Add a quaternion to the current one
  17595. * @param other defines the quaternion to add
  17596. * @returns the current quaternion
  17597. */
  17598. addInPlace(other: Quaternion): Quaternion;
  17599. /**
  17600. * Subtract two quaternions
  17601. * @param other defines the second operand
  17602. * @returns a new quaternion as the subtraction result of the given one from the current one
  17603. */
  17604. subtract(other: Quaternion): Quaternion;
  17605. /**
  17606. * Multiplies the current quaternion by a scale factor
  17607. * @param value defines the scale factor
  17608. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17609. */
  17610. scale(value: number): Quaternion;
  17611. /**
  17612. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17613. * @param scale defines the scale factor
  17614. * @param result defines the Quaternion object where to store the result
  17615. * @returns the unmodified current quaternion
  17616. */
  17617. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17618. /**
  17619. * Multiplies in place the current quaternion by a scale factor
  17620. * @param value defines the scale factor
  17621. * @returns the current modified quaternion
  17622. */
  17623. scaleInPlace(value: number): Quaternion;
  17624. /**
  17625. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17626. * @param scale defines the scale factor
  17627. * @param result defines the Quaternion object where to store the result
  17628. * @returns the unmodified current quaternion
  17629. */
  17630. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17631. /**
  17632. * Multiplies two quaternions
  17633. * @param q1 defines the second operand
  17634. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17635. */
  17636. multiply(q1: Quaternion): Quaternion;
  17637. /**
  17638. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17639. * @param q1 defines the second operand
  17640. * @param result defines the target quaternion
  17641. * @returns the current quaternion
  17642. */
  17643. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17644. /**
  17645. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17646. * @param q1 defines the second operand
  17647. * @returns the currentupdated quaternion
  17648. */
  17649. multiplyInPlace(q1: Quaternion): Quaternion;
  17650. /**
  17651. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17652. * @param ref defines the target quaternion
  17653. * @returns the current quaternion
  17654. */
  17655. conjugateToRef(ref: Quaternion): Quaternion;
  17656. /**
  17657. * Conjugates in place (1-q) the current quaternion
  17658. * @returns the current updated quaternion
  17659. */
  17660. conjugateInPlace(): Quaternion;
  17661. /**
  17662. * Conjugates in place (1-q) the current quaternion
  17663. * @returns a new quaternion
  17664. */
  17665. conjugate(): Quaternion;
  17666. /**
  17667. * Gets length of current quaternion
  17668. * @returns the quaternion length (float)
  17669. */
  17670. length(): number;
  17671. /**
  17672. * Normalize in place the current quaternion
  17673. * @returns the current updated quaternion
  17674. */
  17675. normalize(): Quaternion;
  17676. /**
  17677. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17678. * @param order is a reserved parameter and is ignore for now
  17679. * @returns a new Vector3 containing the Euler angles
  17680. */
  17681. toEulerAngles(order?: string): Vector3;
  17682. /**
  17683. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17684. * @param result defines the vector which will be filled with the Euler angles
  17685. * @param order is a reserved parameter and is ignore for now
  17686. * @returns the current unchanged quaternion
  17687. */
  17688. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17689. /**
  17690. * Updates the given rotation matrix with the current quaternion values
  17691. * @param result defines the target matrix
  17692. * @returns the current unchanged quaternion
  17693. */
  17694. toRotationMatrix(result: Matrix): Quaternion;
  17695. /**
  17696. * Updates the current quaternion from the given rotation matrix values
  17697. * @param matrix defines the source matrix
  17698. * @returns the current updated quaternion
  17699. */
  17700. fromRotationMatrix(matrix: Matrix): Quaternion;
  17701. /**
  17702. * Creates a new quaternion from a rotation matrix
  17703. * @param matrix defines the source matrix
  17704. * @returns a new quaternion created from the given rotation matrix values
  17705. */
  17706. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17707. /**
  17708. * Updates the given quaternion with the given rotation matrix values
  17709. * @param matrix defines the source matrix
  17710. * @param result defines the target quaternion
  17711. */
  17712. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17713. /**
  17714. * Returns the dot product (float) between the quaternions "left" and "right"
  17715. * @param left defines the left operand
  17716. * @param right defines the right operand
  17717. * @returns the dot product
  17718. */
  17719. static Dot(left: Quaternion, right: Quaternion): number;
  17720. /**
  17721. * Checks if the two quaternions are close to each other
  17722. * @param quat0 defines the first quaternion to check
  17723. * @param quat1 defines the second quaternion to check
  17724. * @returns true if the two quaternions are close to each other
  17725. */
  17726. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17727. /**
  17728. * Creates an empty quaternion
  17729. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17730. */
  17731. static Zero(): Quaternion;
  17732. /**
  17733. * Inverse a given quaternion
  17734. * @param q defines the source quaternion
  17735. * @returns a new quaternion as the inverted current quaternion
  17736. */
  17737. static Inverse(q: Quaternion): Quaternion;
  17738. /**
  17739. * Creates an identity quaternion
  17740. * @returns the identity quaternion
  17741. */
  17742. static Identity(): Quaternion;
  17743. /**
  17744. * Gets a boolean indicating if the given quaternion is identity
  17745. * @param quaternion defines the quaternion to check
  17746. * @returns true if the quaternion is identity
  17747. */
  17748. static IsIdentity(quaternion: Quaternion): boolean;
  17749. /**
  17750. * Creates a quaternion from a rotation around an axis
  17751. * @param axis defines the axis to use
  17752. * @param angle defines the angle to use
  17753. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17754. */
  17755. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17756. /**
  17757. * Creates a rotation around an axis and stores it into the given quaternion
  17758. * @param axis defines the axis to use
  17759. * @param angle defines the angle to use
  17760. * @param result defines the target quaternion
  17761. * @returns the target quaternion
  17762. */
  17763. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17764. /**
  17765. * Creates a new quaternion from data stored into an array
  17766. * @param array defines the data source
  17767. * @param offset defines the offset in the source array where the data starts
  17768. * @returns a new quaternion
  17769. */
  17770. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17771. /**
  17772. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17773. * @param yaw defines the rotation around Y axis
  17774. * @param pitch defines the rotation around X axis
  17775. * @param roll defines the rotation around Z axis
  17776. * @returns the new quaternion
  17777. */
  17778. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17779. /**
  17780. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17781. * @param yaw defines the rotation around Y axis
  17782. * @param pitch defines the rotation around X axis
  17783. * @param roll defines the rotation around Z axis
  17784. * @param result defines the target quaternion
  17785. */
  17786. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17787. /**
  17788. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17789. * @param alpha defines the rotation around first axis
  17790. * @param beta defines the rotation around second axis
  17791. * @param gamma defines the rotation around third axis
  17792. * @returns the new quaternion
  17793. */
  17794. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17795. /**
  17796. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17797. * @param alpha defines the rotation around first axis
  17798. * @param beta defines the rotation around second axis
  17799. * @param gamma defines the rotation around third axis
  17800. * @param result defines the target quaternion
  17801. */
  17802. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17803. /**
  17804. * 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)
  17805. * @param axis1 defines the first axis
  17806. * @param axis2 defines the second axis
  17807. * @param axis3 defines the third axis
  17808. * @returns the new quaternion
  17809. */
  17810. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17811. /**
  17812. * 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
  17813. * @param axis1 defines the first axis
  17814. * @param axis2 defines the second axis
  17815. * @param axis3 defines the third axis
  17816. * @param ref defines the target quaternion
  17817. */
  17818. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17819. /**
  17820. * Interpolates between two quaternions
  17821. * @param left defines first quaternion
  17822. * @param right defines second quaternion
  17823. * @param amount defines the gradient to use
  17824. * @returns the new interpolated quaternion
  17825. */
  17826. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17827. /**
  17828. * Interpolates between two quaternions and stores it into a target quaternion
  17829. * @param left defines first quaternion
  17830. * @param right defines second quaternion
  17831. * @param amount defines the gradient to use
  17832. * @param result defines the target quaternion
  17833. */
  17834. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17835. /**
  17836. * Interpolate between two quaternions using Hermite interpolation
  17837. * @param value1 defines first quaternion
  17838. * @param tangent1 defines the incoming tangent
  17839. * @param value2 defines second quaternion
  17840. * @param tangent2 defines the outgoing tangent
  17841. * @param amount defines the target quaternion
  17842. * @returns the new interpolated quaternion
  17843. */
  17844. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17845. }
  17846. /**
  17847. * Class used to store matrix data (4x4)
  17848. */
  17849. class Matrix {
  17850. private static _tempQuaternion;
  17851. private static _xAxis;
  17852. private static _yAxis;
  17853. private static _zAxis;
  17854. private static _updateFlagSeed;
  17855. private static _identityReadOnly;
  17856. private _isIdentity;
  17857. private _isIdentityDirty;
  17858. /**
  17859. * Gets the update flag of the matrix which is an unique number for the matrix.
  17860. * It will be incremented every time the matrix data change.
  17861. * You can use it to speed the comparison between two versions of the same matrix.
  17862. */
  17863. updateFlag: number;
  17864. /**
  17865. * Gets or sets the internal data of the matrix
  17866. */
  17867. m: Float32Array;
  17868. /** @hidden */
  17869. _markAsUpdated(): void;
  17870. /**
  17871. * Creates an empty matrix (filled with zeros)
  17872. */
  17873. constructor();
  17874. /**
  17875. * Check if the current matrix is indentity
  17876. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17877. * @returns true is the matrix is the identity matrix
  17878. */
  17879. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17880. /**
  17881. * Gets the determinant of the matrix
  17882. * @returns the matrix determinant
  17883. */
  17884. determinant(): number;
  17885. /**
  17886. * Returns the matrix as a Float32Array
  17887. * @returns the matrix underlying array
  17888. */
  17889. toArray(): Float32Array;
  17890. /**
  17891. * Returns the matrix as a Float32Array
  17892. * @returns the matrix underlying array.
  17893. */
  17894. asArray(): Float32Array;
  17895. /**
  17896. * Inverts the current matrix in place
  17897. * @returns the current inverted matrix
  17898. */
  17899. invert(): Matrix;
  17900. /**
  17901. * Sets all the matrix elements to zero
  17902. * @returns the current matrix
  17903. */
  17904. reset(): Matrix;
  17905. /**
  17906. * Adds the current matrix with a second one
  17907. * @param other defines the matrix to add
  17908. * @returns a new matrix as the addition of the current matrix and the given one
  17909. */
  17910. add(other: Matrix): Matrix;
  17911. /**
  17912. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17913. * @param other defines the matrix to add
  17914. * @param result defines the target matrix
  17915. * @returns the current matrix
  17916. */
  17917. addToRef(other: Matrix, result: Matrix): Matrix;
  17918. /**
  17919. * Adds in place the given matrix to the current matrix
  17920. * @param other defines the second operand
  17921. * @returns the current updated matrix
  17922. */
  17923. addToSelf(other: Matrix): Matrix;
  17924. /**
  17925. * Sets the given matrix to the current inverted Matrix
  17926. * @param other defines the target matrix
  17927. * @returns the unmodified current matrix
  17928. */
  17929. invertToRef(other: Matrix): Matrix;
  17930. /**
  17931. * Inserts the translation vector (using 3 floats) in the current matrix
  17932. * @param x defines the 1st component of the translation
  17933. * @param y defines the 2nd component of the translation
  17934. * @param z defines the 3rd component of the translation
  17935. * @returns the current updated matrix
  17936. */
  17937. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17938. /**
  17939. * Inserts the translation vector in the current matrix
  17940. * @param vector3 defines the translation to insert
  17941. * @returns the current updated matrix
  17942. */
  17943. setTranslation(vector3: Vector3): Matrix;
  17944. /**
  17945. * Gets the translation value of the current matrix
  17946. * @returns a new Vector3 as the extracted translation from the matrix
  17947. */
  17948. getTranslation(): Vector3;
  17949. /**
  17950. * Fill a Vector3 with the extracted translation from the matrix
  17951. * @param result defines the Vector3 where to store the translation
  17952. * @returns the current matrix
  17953. */
  17954. getTranslationToRef(result: Vector3): Matrix;
  17955. /**
  17956. * Remove rotation and scaling part from the matrix
  17957. * @returns the updated matrix
  17958. */
  17959. removeRotationAndScaling(): Matrix;
  17960. /**
  17961. * Multiply two matrices
  17962. * @param other defines the second operand
  17963. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17964. */
  17965. multiply(other: Matrix): Matrix;
  17966. /**
  17967. * Copy the current matrix from the given one
  17968. * @param other defines the source matrix
  17969. * @returns the current updated matrix
  17970. */
  17971. copyFrom(other: Matrix): Matrix;
  17972. /**
  17973. * Populates the given array from the starting index with the current matrix values
  17974. * @param array defines the target array
  17975. * @param offset defines the offset in the target array where to start storing values
  17976. * @returns the current matrix
  17977. */
  17978. copyToArray(array: Float32Array, offset?: number): Matrix;
  17979. /**
  17980. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17981. * @param other defines the second operand
  17982. * @param result defines the matrix where to store the multiplication
  17983. * @returns the current matrix
  17984. */
  17985. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17986. /**
  17987. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17988. * @param other defines the second operand
  17989. * @param result defines the array where to store the multiplication
  17990. * @param offset defines the offset in the target array where to start storing values
  17991. * @returns the current matrix
  17992. */
  17993. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17994. /**
  17995. * Check equality between this matrix and a second one
  17996. * @param value defines the second matrix to compare
  17997. * @returns true is the current matrix and the given one values are strictly equal
  17998. */
  17999. equals(value: Matrix): boolean;
  18000. /**
  18001. * Clone the current matrix
  18002. * @returns a new matrix from the current matrix
  18003. */
  18004. clone(): Matrix;
  18005. /**
  18006. * Returns the name of the current matrix class
  18007. * @returns the string "Matrix"
  18008. */
  18009. getClassName(): string;
  18010. /**
  18011. * Gets the hash code of the current matrix
  18012. * @returns the hash code
  18013. */
  18014. getHashCode(): number;
  18015. /**
  18016. * Decomposes the current Matrix into a translation, rotation and scaling components
  18017. * @param scale defines the scale vector3 given as a reference to update
  18018. * @param rotation defines the rotation quaternion given as a reference to update
  18019. * @param translation defines the translation vector3 given as a reference to update
  18020. * @returns true if operation was successful
  18021. */
  18022. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  18023. /**
  18024. * Gets specific row of the matrix
  18025. * @param index defines the number of the row to get
  18026. * @returns the index-th row of the current matrix as a new Vector4
  18027. */
  18028. getRow(index: number): Nullable<Vector4>;
  18029. /**
  18030. * Sets the index-th row of the current matrix to the vector4 values
  18031. * @param index defines the number of the row to set
  18032. * @param row defines the target vector4
  18033. * @returns the updated current matrix
  18034. */
  18035. setRow(index: number, row: Vector4): Matrix;
  18036. /**
  18037. * Compute the transpose of the matrix
  18038. * @returns the new transposed matrix
  18039. */
  18040. transpose(): Matrix;
  18041. /**
  18042. * Compute the transpose of the matrix and store it in a given matrix
  18043. * @param result defines the target matrix
  18044. * @returns the current matrix
  18045. */
  18046. transposeToRef(result: Matrix): Matrix;
  18047. /**
  18048. * Sets the index-th row of the current matrix with the given 4 x float values
  18049. * @param index defines the row index
  18050. * @param x defines the x component to set
  18051. * @param y defines the y component to set
  18052. * @param z defines the z component to set
  18053. * @param w defines the w component to set
  18054. * @returns the updated current matrix
  18055. */
  18056. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  18057. /**
  18058. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  18059. * @param scale defines the scale factor
  18060. * @returns a new matrix
  18061. */
  18062. scale(scale: number): Matrix;
  18063. /**
  18064. * Scale the current matrix values by a factor to a given result matrix
  18065. * @param scale defines the scale factor
  18066. * @param result defines the matrix to store the result
  18067. * @returns the current matrix
  18068. */
  18069. scaleToRef(scale: number, result: Matrix): Matrix;
  18070. /**
  18071. * Scale the current matrix values by a factor and add the result to a given matrix
  18072. * @param scale defines the scale factor
  18073. * @param result defines the Matrix to store the result
  18074. * @returns the current matrix
  18075. */
  18076. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  18077. /**
  18078. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  18079. * @param ref matrix to store the result
  18080. */
  18081. toNormalMatrix(ref: Matrix): void;
  18082. /**
  18083. * Gets only rotation part of the current matrix
  18084. * @returns a new matrix sets to the extracted rotation matrix from the current one
  18085. */
  18086. getRotationMatrix(): Matrix;
  18087. /**
  18088. * Extracts the rotation matrix from the current one and sets it as the given "result"
  18089. * @param result defines the target matrix to store data to
  18090. * @returns the current matrix
  18091. */
  18092. getRotationMatrixToRef(result: Matrix): Matrix;
  18093. /**
  18094. * Creates a matrix from an array
  18095. * @param array defines the source array
  18096. * @param offset defines an offset in the source array
  18097. * @returns a new Matrix set from the starting index of the given array
  18098. */
  18099. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  18100. /**
  18101. * Copy the content of an array into a given matrix
  18102. * @param array defines the source array
  18103. * @param offset defines an offset in the source array
  18104. * @param result defines the target matrix
  18105. */
  18106. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  18107. /**
  18108. * Stores an array into a matrix after having multiplied each component by a given factor
  18109. * @param array defines the source array
  18110. * @param offset defines the offset in the source array
  18111. * @param scale defines the scaling factor
  18112. * @param result defines the target matrix
  18113. */
  18114. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  18115. /**
  18116. * Stores a list of values (16) inside a given matrix
  18117. * @param initialM11 defines 1st value of 1st row
  18118. * @param initialM12 defines 2nd value of 1st row
  18119. * @param initialM13 defines 3rd value of 1st row
  18120. * @param initialM14 defines 4th value of 1st row
  18121. * @param initialM21 defines 1st value of 2nd row
  18122. * @param initialM22 defines 2nd value of 2nd row
  18123. * @param initialM23 defines 3rd value of 2nd row
  18124. * @param initialM24 defines 4th value of 2nd row
  18125. * @param initialM31 defines 1st value of 3rd row
  18126. * @param initialM32 defines 2nd value of 3rd row
  18127. * @param initialM33 defines 3rd value of 3rd row
  18128. * @param initialM34 defines 4th value of 3rd row
  18129. * @param initialM41 defines 1st value of 4th row
  18130. * @param initialM42 defines 2nd value of 4th row
  18131. * @param initialM43 defines 3rd value of 4th row
  18132. * @param initialM44 defines 4th value of 4th row
  18133. * @param result defines the target matrix
  18134. */
  18135. 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;
  18136. /**
  18137. * Gets an identity matrix that must not be updated
  18138. */
  18139. static readonly IdentityReadOnly: Matrix;
  18140. /**
  18141. * Creates new matrix from a list of values (16)
  18142. * @param initialM11 defines 1st value of 1st row
  18143. * @param initialM12 defines 2nd value of 1st row
  18144. * @param initialM13 defines 3rd value of 1st row
  18145. * @param initialM14 defines 4th value of 1st row
  18146. * @param initialM21 defines 1st value of 2nd row
  18147. * @param initialM22 defines 2nd value of 2nd row
  18148. * @param initialM23 defines 3rd value of 2nd row
  18149. * @param initialM24 defines 4th value of 2nd row
  18150. * @param initialM31 defines 1st value of 3rd row
  18151. * @param initialM32 defines 2nd value of 3rd row
  18152. * @param initialM33 defines 3rd value of 3rd row
  18153. * @param initialM34 defines 4th value of 3rd row
  18154. * @param initialM41 defines 1st value of 4th row
  18155. * @param initialM42 defines 2nd value of 4th row
  18156. * @param initialM43 defines 3rd value of 4th row
  18157. * @param initialM44 defines 4th value of 4th row
  18158. * @returns the new matrix
  18159. */
  18160. 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;
  18161. /**
  18162. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18163. * @param scale defines the scale vector3
  18164. * @param rotation defines the rotation quaternion
  18165. * @param translation defines the translation vector3
  18166. * @returns a new matrix
  18167. */
  18168. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  18169. /**
  18170. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18171. * @param scale defines the scale vector3
  18172. * @param rotation defines the rotation quaternion
  18173. * @param translation defines the translation vector3
  18174. * @param result defines the target matrix
  18175. */
  18176. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  18177. /**
  18178. * Creates a new identity matrix
  18179. * @returns a new identity matrix
  18180. */
  18181. static Identity(): Matrix;
  18182. /**
  18183. * Creates a new identity matrix and stores the result in a given matrix
  18184. * @param result defines the target matrix
  18185. */
  18186. static IdentityToRef(result: Matrix): void;
  18187. /**
  18188. * Creates a new zero matrix
  18189. * @returns a new zero matrix
  18190. */
  18191. static Zero(): Matrix;
  18192. /**
  18193. * Creates a new rotation matrix for "angle" radians around the X axis
  18194. * @param angle defines the angle (in radians) to use
  18195. * @return the new matrix
  18196. */
  18197. static RotationX(angle: number): Matrix;
  18198. /**
  18199. * Creates a new matrix as the invert of a given matrix
  18200. * @param source defines the source matrix
  18201. * @returns the new matrix
  18202. */
  18203. static Invert(source: Matrix): Matrix;
  18204. /**
  18205. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  18206. * @param angle defines the angle (in radians) to use
  18207. * @param result defines the target matrix
  18208. */
  18209. static RotationXToRef(angle: number, result: Matrix): void;
  18210. /**
  18211. * Creates a new rotation matrix for "angle" radians around the Y axis
  18212. * @param angle defines the angle (in radians) to use
  18213. * @return the new matrix
  18214. */
  18215. static RotationY(angle: number): Matrix;
  18216. /**
  18217. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  18218. * @param angle defines the angle (in radians) to use
  18219. * @param result defines the target matrix
  18220. */
  18221. static RotationYToRef(angle: number, result: Matrix): void;
  18222. /**
  18223. * Creates a new rotation matrix for "angle" radians around the Z axis
  18224. * @param angle defines the angle (in radians) to use
  18225. * @return the new matrix
  18226. */
  18227. static RotationZ(angle: number): Matrix;
  18228. /**
  18229. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  18230. * @param angle defines the angle (in radians) to use
  18231. * @param result defines the target matrix
  18232. */
  18233. static RotationZToRef(angle: number, result: Matrix): void;
  18234. /**
  18235. * Creates a new rotation matrix for "angle" radians around the given axis
  18236. * @param axis defines the axis to use
  18237. * @param angle defines the angle (in radians) to use
  18238. * @return the new matrix
  18239. */
  18240. static RotationAxis(axis: Vector3, angle: number): Matrix;
  18241. /**
  18242. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  18243. * @param axis defines the axis to use
  18244. * @param angle defines the angle (in radians) to use
  18245. * @param result defines the target matrix
  18246. */
  18247. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  18248. /**
  18249. * Creates a rotation matrix
  18250. * @param yaw defines the yaw angle in radians (Y axis)
  18251. * @param pitch defines the pitch angle in radians (X axis)
  18252. * @param roll defines the roll angle in radians (X axis)
  18253. * @returns the new rotation matrix
  18254. */
  18255. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  18256. /**
  18257. * Creates a rotation matrix and stores it in a given matrix
  18258. * @param yaw defines the yaw angle in radians (Y axis)
  18259. * @param pitch defines the pitch angle in radians (X axis)
  18260. * @param roll defines the roll angle in radians (X axis)
  18261. * @param result defines the target matrix
  18262. */
  18263. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  18264. /**
  18265. * Creates a scaling matrix
  18266. * @param x defines the scale factor on X axis
  18267. * @param y defines the scale factor on Y axis
  18268. * @param z defines the scale factor on Z axis
  18269. * @returns the new matrix
  18270. */
  18271. static Scaling(x: number, y: number, z: number): Matrix;
  18272. /**
  18273. * Creates a scaling matrix and stores it in a given matrix
  18274. * @param x defines the scale factor on X axis
  18275. * @param y defines the scale factor on Y axis
  18276. * @param z defines the scale factor on Z axis
  18277. * @param result defines the target matrix
  18278. */
  18279. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18280. /**
  18281. * Creates a translation matrix
  18282. * @param x defines the translation on X axis
  18283. * @param y defines the translation on Y axis
  18284. * @param z defines the translationon Z axis
  18285. * @returns the new matrix
  18286. */
  18287. static Translation(x: number, y: number, z: number): Matrix;
  18288. /**
  18289. * Creates a translation matrix and stores it in a given matrix
  18290. * @param x defines the translation on X axis
  18291. * @param y defines the translation on Y axis
  18292. * @param z defines the translationon Z axis
  18293. * @param result defines the target matrix
  18294. */
  18295. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18296. /**
  18297. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18298. * @param startValue defines the start value
  18299. * @param endValue defines the end value
  18300. * @param gradient defines the gradient factor
  18301. * @returns the new matrix
  18302. */
  18303. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18304. /**
  18305. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18306. * @param startValue defines the start value
  18307. * @param endValue defines the end value
  18308. * @param gradient defines the gradient factor
  18309. * @param result defines the Matrix object where to store data
  18310. */
  18311. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18312. /**
  18313. * Builds a new matrix whose values are computed by:
  18314. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18315. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18316. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18317. * @param startValue defines the first matrix
  18318. * @param endValue defines the second matrix
  18319. * @param gradient defines the gradient between the two matrices
  18320. * @returns the new matrix
  18321. */
  18322. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18323. /**
  18324. * Update a matrix to values which are computed by:
  18325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18328. * @param startValue defines the first matrix
  18329. * @param endValue defines the second matrix
  18330. * @param gradient defines the gradient between the two matrices
  18331. * @param result defines the target matrix
  18332. */
  18333. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18334. /**
  18335. * 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"
  18336. * This function works in left handed mode
  18337. * @param eye defines the final position of the entity
  18338. * @param target defines where the entity should look at
  18339. * @param up defines the up vector for the entity
  18340. * @returns the new matrix
  18341. */
  18342. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18343. /**
  18344. * 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".
  18345. * This function works in left handed mode
  18346. * @param eye defines the final position of the entity
  18347. * @param target defines where the entity should look at
  18348. * @param up defines the up vector for the entity
  18349. * @param result defines the target matrix
  18350. */
  18351. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18352. /**
  18353. * 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"
  18354. * This function works in right handed mode
  18355. * @param eye defines the final position of the entity
  18356. * @param target defines where the entity should look at
  18357. * @param up defines the up vector for the entity
  18358. * @returns the new matrix
  18359. */
  18360. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18361. /**
  18362. * 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".
  18363. * This function works in right handed mode
  18364. * @param eye defines the final position of the entity
  18365. * @param target defines where the entity should look at
  18366. * @param up defines the up vector for the entity
  18367. * @param result defines the target matrix
  18368. */
  18369. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18370. /**
  18371. * Create a left-handed orthographic projection matrix
  18372. * @param width defines the viewport width
  18373. * @param height defines the viewport height
  18374. * @param znear defines the near clip plane
  18375. * @param zfar defines the far clip plane
  18376. * @returns a new matrix as a left-handed orthographic projection matrix
  18377. */
  18378. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18379. /**
  18380. * Store a left-handed orthographic projection to a given matrix
  18381. * @param width defines the viewport width
  18382. * @param height defines the viewport height
  18383. * @param znear defines the near clip plane
  18384. * @param zfar defines the far clip plane
  18385. * @param result defines the target matrix
  18386. */
  18387. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18388. /**
  18389. * Create a left-handed orthographic projection matrix
  18390. * @param left defines the viewport left coordinate
  18391. * @param right defines the viewport right coordinate
  18392. * @param bottom defines the viewport bottom coordinate
  18393. * @param top defines the viewport top coordinate
  18394. * @param znear defines the near clip plane
  18395. * @param zfar defines the far clip plane
  18396. * @returns a new matrix as a left-handed orthographic projection matrix
  18397. */
  18398. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18399. /**
  18400. * Stores a left-handed orthographic projection into a given matrix
  18401. * @param left defines the viewport left coordinate
  18402. * @param right defines the viewport right coordinate
  18403. * @param bottom defines the viewport bottom coordinate
  18404. * @param top defines the viewport top coordinate
  18405. * @param znear defines the near clip plane
  18406. * @param zfar defines the far clip plane
  18407. * @param result defines the target matrix
  18408. */
  18409. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18410. /**
  18411. * Creates a right-handed orthographic projection matrix
  18412. * @param left defines the viewport left coordinate
  18413. * @param right defines the viewport right coordinate
  18414. * @param bottom defines the viewport bottom coordinate
  18415. * @param top defines the viewport top coordinate
  18416. * @param znear defines the near clip plane
  18417. * @param zfar defines the far clip plane
  18418. * @returns a new matrix as a right-handed orthographic projection matrix
  18419. */
  18420. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18421. /**
  18422. * Stores a right-handed orthographic projection into a given matrix
  18423. * @param left defines the viewport left coordinate
  18424. * @param right defines the viewport right coordinate
  18425. * @param bottom defines the viewport bottom coordinate
  18426. * @param top defines the viewport top coordinate
  18427. * @param znear defines the near clip plane
  18428. * @param zfar defines the far clip plane
  18429. * @param result defines the target matrix
  18430. */
  18431. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18432. /**
  18433. * Creates a left-handed perspective projection matrix
  18434. * @param width defines the viewport width
  18435. * @param height defines the viewport height
  18436. * @param znear defines the near clip plane
  18437. * @param zfar defines the far clip plane
  18438. * @returns a new matrix as a left-handed perspective projection matrix
  18439. */
  18440. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18441. /**
  18442. * Creates a left-handed perspective projection matrix
  18443. * @param fov defines the horizontal field of view
  18444. * @param aspect defines the aspect ratio
  18445. * @param znear defines the near clip plane
  18446. * @param zfar defines the far clip plane
  18447. * @returns a new matrix as a left-handed perspective projection matrix
  18448. */
  18449. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18450. /**
  18451. * Stores a left-handed perspective projection into a given matrix
  18452. * @param fov defines the horizontal field of view
  18453. * @param aspect defines the aspect ratio
  18454. * @param znear defines the near clip plane
  18455. * @param zfar defines the far clip plane
  18456. * @param result defines the target matrix
  18457. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18458. */
  18459. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18460. /**
  18461. * Creates a right-handed perspective projection matrix
  18462. * @param fov defines the horizontal field of view
  18463. * @param aspect defines the aspect ratio
  18464. * @param znear defines the near clip plane
  18465. * @param zfar defines the far clip plane
  18466. * @returns a new matrix as a right-handed perspective projection matrix
  18467. */
  18468. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18469. /**
  18470. * Stores a right-handed perspective projection into a given matrix
  18471. * @param fov defines the horizontal field of view
  18472. * @param aspect defines the aspect ratio
  18473. * @param znear defines the near clip plane
  18474. * @param zfar defines the far clip plane
  18475. * @param result defines the target matrix
  18476. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18477. */
  18478. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18479. /**
  18480. * Stores a perspective projection for WebVR info a given matrix
  18481. * @param fov defines the field of view
  18482. * @param znear defines the near clip plane
  18483. * @param zfar defines the far clip plane
  18484. * @param result defines the target matrix
  18485. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18486. */
  18487. static PerspectiveFovWebVRToRef(fov: {
  18488. upDegrees: number;
  18489. downDegrees: number;
  18490. leftDegrees: number;
  18491. rightDegrees: number;
  18492. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18493. /**
  18494. * Computes a complete transformation matrix
  18495. * @param viewport defines the viewport to use
  18496. * @param world defines the world matrix
  18497. * @param view defines the view matrix
  18498. * @param projection defines the projection matrix
  18499. * @param zmin defines the near clip plane
  18500. * @param zmax defines the far clip plane
  18501. * @returns the transformation matrix
  18502. */
  18503. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18504. /**
  18505. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18506. * @param matrix defines the matrix to use
  18507. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18508. */
  18509. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18510. /**
  18511. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18512. * @param matrix defines the matrix to use
  18513. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18514. */
  18515. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18516. /**
  18517. * Compute the transpose of a given matrix
  18518. * @param matrix defines the matrix to transpose
  18519. * @returns the new matrix
  18520. */
  18521. static Transpose(matrix: Matrix): Matrix;
  18522. /**
  18523. * Compute the transpose of a matrix and store it in a target matrix
  18524. * @param matrix defines the matrix to transpose
  18525. * @param result defines the target matrix
  18526. */
  18527. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18528. /**
  18529. * Computes a reflection matrix from a plane
  18530. * @param plane defines the reflection plane
  18531. * @returns a new matrix
  18532. */
  18533. static Reflection(plane: Plane): Matrix;
  18534. /**
  18535. * Computes a reflection matrix from a plane
  18536. * @param plane defines the reflection plane
  18537. * @param result defines the target matrix
  18538. */
  18539. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18540. /**
  18541. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18542. * @param xaxis defines the value of the 1st axis
  18543. * @param yaxis defines the value of the 2nd axis
  18544. * @param zaxis defines the value of the 3rd axis
  18545. * @param result defines the target matrix
  18546. */
  18547. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18548. /**
  18549. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18550. * @param quat defines the quaternion to use
  18551. * @param result defines the target matrix
  18552. */
  18553. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18554. }
  18555. class Plane {
  18556. normal: Vector3;
  18557. d: number;
  18558. /**
  18559. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18560. */
  18561. constructor(a: number, b: number, c: number, d: number);
  18562. /**
  18563. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18564. */
  18565. asArray(): number[];
  18566. /**
  18567. * Returns a new plane copied from the current Plane.
  18568. */
  18569. clone(): Plane;
  18570. /**
  18571. * Returns the string "Plane".
  18572. */
  18573. getClassName(): string;
  18574. /**
  18575. * Returns the Plane hash code.
  18576. */
  18577. getHashCode(): number;
  18578. /**
  18579. * Normalize the current Plane in place.
  18580. * Returns the updated Plane.
  18581. */
  18582. normalize(): Plane;
  18583. /**
  18584. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18585. */
  18586. transform(transformation: Matrix): Plane;
  18587. /**
  18588. * Returns the dot product (float) of the point coordinates and the plane normal.
  18589. */
  18590. dotCoordinate(point: Vector3): number;
  18591. /**
  18592. * Updates the current Plane from the plane defined by the three given points.
  18593. * Returns the updated Plane.
  18594. */
  18595. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18596. /**
  18597. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18598. */
  18599. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18600. /**
  18601. * Returns the signed distance (float) from the given point to the Plane.
  18602. */
  18603. signedDistanceTo(point: Vector3): number;
  18604. /**
  18605. * Returns a new Plane from the given array.
  18606. */
  18607. static FromArray(array: ArrayLike<number>): Plane;
  18608. /**
  18609. * Returns a new Plane defined by the three given points.
  18610. */
  18611. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18612. /**
  18613. * Returns a new Plane the normal vector to this plane at the given origin point.
  18614. * Note : the vector "normal" is updated because normalized.
  18615. */
  18616. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18617. /**
  18618. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18619. */
  18620. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18621. }
  18622. class Viewport {
  18623. x: number;
  18624. y: number;
  18625. width: number;
  18626. height: number;
  18627. /**
  18628. * Creates a Viewport object located at (x, y) and sized (width, height).
  18629. */
  18630. constructor(x: number, y: number, width: number, height: number);
  18631. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18632. /**
  18633. * Returns a new Viewport copied from the current one.
  18634. */
  18635. clone(): Viewport;
  18636. }
  18637. class Frustum {
  18638. /**
  18639. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18640. */
  18641. static GetPlanes(transform: Matrix): Plane[];
  18642. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18643. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18644. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18645. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18646. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18647. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18648. /**
  18649. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18650. */
  18651. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18652. }
  18653. /** Defines supported spaces */
  18654. enum Space {
  18655. /** Local (object) space */
  18656. LOCAL = 0,
  18657. /** World space */
  18658. WORLD = 1,
  18659. /** Bone space */
  18660. BONE = 2
  18661. }
  18662. /** Defines the 3 main axes */
  18663. class Axis {
  18664. /** X axis */
  18665. static X: Vector3;
  18666. /** Y axis */
  18667. static Y: Vector3;
  18668. /** Z axis */
  18669. static Z: Vector3;
  18670. }
  18671. class BezierCurve {
  18672. /**
  18673. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18674. */
  18675. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18676. }
  18677. /**
  18678. * Defines potential orientation for back face culling
  18679. */
  18680. enum Orientation {
  18681. /**
  18682. * Clockwise
  18683. */
  18684. CW = 0,
  18685. /** Counter clockwise */
  18686. CCW = 1
  18687. }
  18688. /**
  18689. * Defines angle representation
  18690. */
  18691. class Angle {
  18692. private _radians;
  18693. /**
  18694. * Creates an Angle object of "radians" radians (float).
  18695. */
  18696. constructor(radians: number);
  18697. /**
  18698. * Get value in degrees
  18699. * @returns the Angle value in degrees (float)
  18700. */
  18701. degrees(): number;
  18702. /**
  18703. * Get value in radians
  18704. * @returns the Angle value in radians (float)
  18705. */
  18706. radians(): number;
  18707. /**
  18708. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18709. * @param a defines first vector
  18710. * @param b defines second vector
  18711. * @returns a new Angle
  18712. */
  18713. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18714. /**
  18715. * Gets a new Angle object from the given float in radians
  18716. * @param radians defines the angle value in radians
  18717. * @returns a new Angle
  18718. */
  18719. static FromRadians(radians: number): Angle;
  18720. /**
  18721. * Gets a new Angle object from the given float in degrees
  18722. * @param degrees defines the angle value in degrees
  18723. * @returns a new Angle
  18724. */
  18725. static FromDegrees(degrees: number): Angle;
  18726. }
  18727. class Arc2 {
  18728. startPoint: Vector2;
  18729. midPoint: Vector2;
  18730. endPoint: Vector2;
  18731. centerPoint: Vector2;
  18732. radius: number;
  18733. angle: Angle;
  18734. startAngle: Angle;
  18735. orientation: Orientation;
  18736. /**
  18737. * Creates an Arc object from the three given points : start, middle and end.
  18738. */
  18739. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18740. }
  18741. class Path2 {
  18742. private _points;
  18743. private _length;
  18744. closed: boolean;
  18745. /**
  18746. * Creates a Path2 object from the starting 2D coordinates x and y.
  18747. */
  18748. constructor(x: number, y: number);
  18749. /**
  18750. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18751. * Returns the updated Path2.
  18752. */
  18753. addLineTo(x: number, y: number): Path2;
  18754. /**
  18755. * 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.
  18756. * Returns the updated Path2.
  18757. */
  18758. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18759. /**
  18760. * Closes the Path2.
  18761. * Returns the Path2.
  18762. */
  18763. close(): Path2;
  18764. /**
  18765. * Returns the Path2 total length (float).
  18766. */
  18767. length(): number;
  18768. /**
  18769. * Returns the Path2 internal array of points.
  18770. */
  18771. getPoints(): Vector2[];
  18772. /**
  18773. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18774. */
  18775. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18776. /**
  18777. * Returns a new Path2 starting at the coordinates (x, y).
  18778. */
  18779. static StartingAt(x: number, y: number): Path2;
  18780. }
  18781. class Path3D {
  18782. path: Vector3[];
  18783. private _curve;
  18784. private _distances;
  18785. private _tangents;
  18786. private _normals;
  18787. private _binormals;
  18788. private _raw;
  18789. /**
  18790. * new Path3D(path, normal, raw)
  18791. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18792. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18793. * path : an array of Vector3, the curve axis of the Path3D
  18794. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18795. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18796. */
  18797. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18798. /**
  18799. * Returns the Path3D array of successive Vector3 designing its curve.
  18800. */
  18801. getCurve(): Vector3[];
  18802. /**
  18803. * Returns an array populated with tangent vectors on each Path3D curve point.
  18804. */
  18805. getTangents(): Vector3[];
  18806. /**
  18807. * Returns an array populated with normal vectors on each Path3D curve point.
  18808. */
  18809. getNormals(): Vector3[];
  18810. /**
  18811. * Returns an array populated with binormal vectors on each Path3D curve point.
  18812. */
  18813. getBinormals(): Vector3[];
  18814. /**
  18815. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18816. */
  18817. getDistances(): number[];
  18818. /**
  18819. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18820. * Returns the same object updated.
  18821. */
  18822. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18823. private _compute;
  18824. private _getFirstNonNullVector;
  18825. private _getLastNonNullVector;
  18826. private _normalVector;
  18827. }
  18828. class Curve3 {
  18829. private _points;
  18830. private _length;
  18831. /**
  18832. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18833. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18834. * @param v1 (Vector3) the control point
  18835. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18836. * @param nbPoints (integer) the wanted number of points in the curve
  18837. */
  18838. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18839. /**
  18840. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18841. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18842. * @param v1 (Vector3) the first control point
  18843. * @param v2 (Vector3) the second control point
  18844. * @param v3 (Vector3) the end point of the Cubic Bezier
  18845. * @param nbPoints (integer) the wanted number of points in the curve
  18846. */
  18847. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18848. /**
  18849. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18850. * @param p1 (Vector3) the origin point of the Hermite Spline
  18851. * @param t1 (Vector3) the tangent vector at the origin point
  18852. * @param p2 (Vector3) the end point of the Hermite Spline
  18853. * @param t2 (Vector3) the tangent vector at the end point
  18854. * @param nbPoints (integer) the wanted number of points in the curve
  18855. */
  18856. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18857. /**
  18858. * Returns a Curve3 object along a CatmullRom Spline curve :
  18859. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18860. * @param nbPoints (integer) the wanted number of points between each curve control points
  18861. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18862. */
  18863. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18864. /**
  18865. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18866. * A Curve3 is designed from a series of successive Vector3.
  18867. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18868. */
  18869. constructor(points: Vector3[]);
  18870. /**
  18871. * Returns the Curve3 stored array of successive Vector3
  18872. */
  18873. getPoints(): Vector3[];
  18874. /**
  18875. * Returns the computed length (float) of the curve.
  18876. */
  18877. length(): number;
  18878. /**
  18879. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18880. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18881. * curveA and curveB keep unchanged.
  18882. */
  18883. continue(curve: Curve3): Curve3;
  18884. private _computeLength;
  18885. }
  18886. class PositionNormalVertex {
  18887. position: Vector3;
  18888. normal: Vector3;
  18889. constructor(position?: Vector3, normal?: Vector3);
  18890. clone(): PositionNormalVertex;
  18891. }
  18892. class PositionNormalTextureVertex {
  18893. position: Vector3;
  18894. normal: Vector3;
  18895. uv: Vector2;
  18896. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18897. clone(): PositionNormalTextureVertex;
  18898. }
  18899. class Tmp {
  18900. static Color3: Color3[];
  18901. static Color4: Color4[];
  18902. static Vector2: Vector2[];
  18903. static Vector3: Vector3[];
  18904. static Vector4: Vector4[];
  18905. static Quaternion: Quaternion[];
  18906. static Matrix: Matrix[];
  18907. }
  18908. }
  18909. declare module BABYLON {
  18910. /**
  18911. * Class representing spherical polynomial coefficients to the 3rd degree
  18912. */
  18913. class SphericalPolynomial {
  18914. /**
  18915. * The x coefficients of the spherical polynomial
  18916. */
  18917. x: Vector3;
  18918. /**
  18919. * The y coefficients of the spherical polynomial
  18920. */
  18921. y: Vector3;
  18922. /**
  18923. * The z coefficients of the spherical polynomial
  18924. */
  18925. z: Vector3;
  18926. /**
  18927. * The xx coefficients of the spherical polynomial
  18928. */
  18929. xx: Vector3;
  18930. /**
  18931. * The yy coefficients of the spherical polynomial
  18932. */
  18933. yy: Vector3;
  18934. /**
  18935. * The zz coefficients of the spherical polynomial
  18936. */
  18937. zz: Vector3;
  18938. /**
  18939. * The xy coefficients of the spherical polynomial
  18940. */
  18941. xy: Vector3;
  18942. /**
  18943. * The yz coefficients of the spherical polynomial
  18944. */
  18945. yz: Vector3;
  18946. /**
  18947. * The zx coefficients of the spherical polynomial
  18948. */
  18949. zx: Vector3;
  18950. /**
  18951. * Adds an ambient color to the spherical polynomial
  18952. * @param color the color to add
  18953. */
  18954. addAmbient(color: Color3): void;
  18955. /**
  18956. * Scales the spherical polynomial by the given amount
  18957. * @param scale the amount to scale
  18958. */
  18959. scale(scale: number): void;
  18960. /**
  18961. * Gets the spherical polynomial from harmonics
  18962. * @param harmonics the spherical harmonics
  18963. * @returns the spherical polynomial
  18964. */
  18965. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18966. /**
  18967. * Constructs a spherical polynomial from an array.
  18968. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  18969. * @returns the spherical polynomial
  18970. */
  18971. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  18972. }
  18973. /**
  18974. * Class representing spherical harmonics coefficients to the 3rd degree
  18975. */
  18976. class SphericalHarmonics {
  18977. /**
  18978. * The l0,0 coefficients of the spherical harmonics
  18979. */
  18980. l00: Vector3;
  18981. /**
  18982. * The l1,-1 coefficients of the spherical harmonics
  18983. */
  18984. l1_1: Vector3;
  18985. /**
  18986. * The l1,0 coefficients of the spherical harmonics
  18987. */
  18988. l10: Vector3;
  18989. /**
  18990. * The l1,1 coefficients of the spherical harmonics
  18991. */
  18992. l11: Vector3;
  18993. /**
  18994. * The l2,-2 coefficients of the spherical harmonics
  18995. */
  18996. l2_2: Vector3;
  18997. /**
  18998. * The l2,-1 coefficients of the spherical harmonics
  18999. */
  19000. l2_1: Vector3;
  19001. /**
  19002. * The l2,0 coefficients of the spherical harmonics
  19003. */
  19004. l20: Vector3;
  19005. /**
  19006. * The l2,1 coefficients of the spherical harmonics
  19007. */
  19008. l21: Vector3;
  19009. /**
  19010. * The l2,2 coefficients of the spherical harmonics
  19011. */
  19012. lL22: Vector3;
  19013. /**
  19014. * Adds a light to the spherical harmonics
  19015. * @param direction the direction of the light
  19016. * @param color the color of the light
  19017. * @param deltaSolidAngle the delta solid angle of the light
  19018. */
  19019. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  19020. /**
  19021. * Scales the spherical harmonics by the given amount
  19022. * @param scale the amount to scale
  19023. */
  19024. scale(scale: number): void;
  19025. /**
  19026. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  19027. *
  19028. * ```
  19029. * E_lm = A_l * L_lm
  19030. * ```
  19031. *
  19032. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  19033. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  19034. * the scaling factors are given in equation 9.
  19035. */
  19036. convertIncidentRadianceToIrradiance(): void;
  19037. /**
  19038. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  19039. *
  19040. * ```
  19041. * L = (1/pi) * E * rho
  19042. * ```
  19043. *
  19044. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  19045. */
  19046. convertIrradianceToLambertianRadiance(): void;
  19047. /**
  19048. * Gets the spherical harmonics from polynomial
  19049. * @param polynomial the spherical polynomial
  19050. * @returns the spherical harmonics
  19051. */
  19052. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  19053. /**
  19054. * Constructs a spherical harmonics from an array.
  19055. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  19056. * @returns the spherical harmonics
  19057. */
  19058. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  19059. }
  19060. }
  19061. declare module BABYLON {
  19062. /**
  19063. * Class used to store all common mesh properties
  19064. */
  19065. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19066. /** No occlusion */
  19067. static OCCLUSION_TYPE_NONE: number;
  19068. /** Occlusion set to optimisitic */
  19069. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19070. /** Occlusion set to strict */
  19071. static OCCLUSION_TYPE_STRICT: number;
  19072. /** Use an accurante occlusion algorithm */
  19073. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19074. /** Use a conservative occlusion algorithm */
  19075. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19076. /**
  19077. * No billboard
  19078. */
  19079. static readonly BILLBOARDMODE_NONE: number;
  19080. /** Billboard on X axis */
  19081. static readonly BILLBOARDMODE_X: number;
  19082. /** Billboard on Y axis */
  19083. static readonly BILLBOARDMODE_Y: number;
  19084. /** Billboard on Z axis */
  19085. static readonly BILLBOARDMODE_Z: number;
  19086. /** Billboard on all axes */
  19087. static readonly BILLBOARDMODE_ALL: number;
  19088. private _facetPositions;
  19089. private _facetNormals;
  19090. private _facetPartitioning;
  19091. private _facetNb;
  19092. private _partitioningSubdivisions;
  19093. private _partitioningBBoxRatio;
  19094. private _facetDataEnabled;
  19095. private _facetParameters;
  19096. private _bbSize;
  19097. private _subDiv;
  19098. private _facetDepthSort;
  19099. private _facetDepthSortEnabled;
  19100. private _depthSortedIndices;
  19101. private _depthSortedFacets;
  19102. private _facetDepthSortFunction;
  19103. private _facetDepthSortFrom;
  19104. private _facetDepthSortOrigin;
  19105. private _invertedMatrix;
  19106. /**
  19107. * Gets the number of facets in the mesh
  19108. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19109. */
  19110. readonly facetNb: number;
  19111. /**
  19112. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19114. */
  19115. partitioningSubdivisions: number;
  19116. /**
  19117. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19118. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19120. */
  19121. partitioningBBoxRatio: number;
  19122. /**
  19123. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19124. * Works only for updatable meshes.
  19125. * Doesn't work with multi-materials
  19126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19127. */
  19128. mustDepthSortFacets: boolean;
  19129. /**
  19130. * The location (Vector3) where the facet depth sort must be computed from.
  19131. * By default, the active camera position.
  19132. * Used only when facet depth sort is enabled
  19133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19134. */
  19135. facetDepthSortFrom: Vector3;
  19136. /**
  19137. * gets a boolean indicating if facetData is enabled
  19138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19139. */
  19140. readonly isFacetDataEnabled: boolean;
  19141. /** @hidden */
  19142. _updateNonUniformScalingState(value: boolean): boolean;
  19143. /**
  19144. * An event triggered when this mesh collides with another one
  19145. */
  19146. onCollideObservable: Observable<AbstractMesh>;
  19147. private _onCollideObserver;
  19148. /** Set a function to call when this mesh collides with another one */
  19149. onCollide: () => void;
  19150. /**
  19151. * An event triggered when the collision's position changes
  19152. */
  19153. onCollisionPositionChangeObservable: Observable<Vector3>;
  19154. private _onCollisionPositionChangeObserver;
  19155. /** Set a function to call when the collision's position changes */
  19156. onCollisionPositionChange: () => void;
  19157. /**
  19158. * An event triggered when material is changed
  19159. */
  19160. onMaterialChangedObservable: Observable<AbstractMesh>;
  19161. /**
  19162. * Gets or sets the orientation for POV movement & rotation
  19163. */
  19164. definedFacingForward: boolean;
  19165. /**
  19166. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19167. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19168. * * 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.
  19169. * @see http://doc.babylonjs.com/features/occlusionquery
  19170. */
  19171. occlusionQueryAlgorithmType: number;
  19172. /**
  19173. * 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:
  19174. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19175. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19176. * * 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.
  19177. * @see http://doc.babylonjs.com/features/occlusionquery
  19178. */
  19179. occlusionType: number;
  19180. /**
  19181. * 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.
  19182. * The default value is -1 which means don't break the query and wait till the result
  19183. * @see http://doc.babylonjs.com/features/occlusionquery
  19184. */
  19185. occlusionRetryCount: number;
  19186. /** @hidden */
  19187. _occlusionInternalRetryCounter: number;
  19188. /** @hidden */
  19189. _isOccluded: boolean;
  19190. /**
  19191. * 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
  19192. * @see http://doc.babylonjs.com/features/occlusionquery
  19193. */
  19194. isOccluded: boolean;
  19195. /** @hidden */
  19196. _isOcclusionQueryInProgress: boolean;
  19197. /**
  19198. * Flag to check the progress status of the query
  19199. * @see http://doc.babylonjs.com/features/occlusionquery
  19200. */
  19201. readonly isOcclusionQueryInProgress: boolean;
  19202. /** @hidden */
  19203. _occlusionQuery: Nullable<WebGLQuery>;
  19204. private _visibility;
  19205. /**
  19206. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19207. */
  19208. /**
  19209. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19210. */
  19211. visibility: number;
  19212. /** Gets or sets the alpha index used to sort transparent meshes
  19213. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19214. */
  19215. alphaIndex: number;
  19216. /**
  19217. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19218. */
  19219. isVisible: boolean;
  19220. /**
  19221. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19222. */
  19223. isPickable: boolean;
  19224. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19225. showSubMeshesBoundingBox: boolean;
  19226. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19228. */
  19229. isBlocker: boolean;
  19230. /**
  19231. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19232. */
  19233. enablePointerMoveEvents: boolean;
  19234. /**
  19235. * Specifies the rendering group id for this mesh (0 by default)
  19236. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19237. */
  19238. renderingGroupId: number;
  19239. private _material;
  19240. /** Gets or sets current material */
  19241. material: Nullable<Material>;
  19242. private _receiveShadows;
  19243. /**
  19244. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19245. * @see http://doc.babylonjs.com/babylon101/shadows
  19246. */
  19247. receiveShadows: boolean;
  19248. /**
  19249. * Gets or sets a boolean indicating if the outline must be rendered as well
  19250. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19251. */
  19252. renderOutline: boolean;
  19253. /** Defines color to use when rendering outline */
  19254. outlineColor: Color3;
  19255. /** Define width to use when rendering outline */
  19256. outlineWidth: number;
  19257. /**
  19258. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19259. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19260. */
  19261. renderOverlay: boolean;
  19262. /** Defines color to use when rendering overlay */
  19263. overlayColor: Color3;
  19264. /** Defines alpha to use when rendering overlay */
  19265. overlayAlpha: number;
  19266. private _hasVertexAlpha;
  19267. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19268. hasVertexAlpha: boolean;
  19269. private _useVertexColors;
  19270. /** 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) */
  19271. useVertexColors: boolean;
  19272. private _computeBonesUsingShaders;
  19273. /**
  19274. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19275. */
  19276. computeBonesUsingShaders: boolean;
  19277. private _numBoneInfluencers;
  19278. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19279. numBoneInfluencers: number;
  19280. private _applyFog;
  19281. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19282. applyFog: boolean;
  19283. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19284. useOctreeForRenderingSelection: boolean;
  19285. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19286. useOctreeForPicking: boolean;
  19287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19288. useOctreeForCollisions: boolean;
  19289. private _layerMask;
  19290. /**
  19291. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19292. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19293. */
  19294. layerMask: number;
  19295. /**
  19296. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19297. */
  19298. alwaysSelectAsActiveMesh: boolean;
  19299. /**
  19300. * Gets or sets the current action manager
  19301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19302. */
  19303. actionManager: Nullable<ActionManager>;
  19304. /**
  19305. * Gets or sets impostor used for physic simulation
  19306. * @see http://doc.babylonjs.com/features/physics_engine
  19307. */
  19308. physicsImpostor: Nullable<PhysicsImpostor>;
  19309. private _checkCollisions;
  19310. private _collisionMask;
  19311. private _collisionGroup;
  19312. /**
  19313. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19315. */
  19316. ellipsoid: Vector3;
  19317. /**
  19318. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19320. */
  19321. ellipsoidOffset: Vector3;
  19322. private _collider;
  19323. private _oldPositionForCollisions;
  19324. private _diffPositionForCollisions;
  19325. /**
  19326. * Gets or sets a collision mask used to mask collisions (default is -1).
  19327. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19328. */
  19329. collisionMask: number;
  19330. /**
  19331. * Gets or sets the current collision group mask (-1 by default).
  19332. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19333. */
  19334. collisionGroup: number;
  19335. /**
  19336. * Defines edge width used when edgesRenderer is enabled
  19337. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19338. */
  19339. edgesWidth: number;
  19340. /**
  19341. * Defines edge color used when edgesRenderer is enabled
  19342. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19343. */
  19344. edgesColor: Color4;
  19345. /** @hidden */
  19346. _edgesRenderer: Nullable<EdgesRenderer>;
  19347. private _collisionsTransformMatrix;
  19348. private _collisionsScalingMatrix;
  19349. /** @hidden */
  19350. _masterMesh: Nullable<AbstractMesh>;
  19351. /** @hidden */
  19352. _boundingInfo: Nullable<BoundingInfo>;
  19353. /** @hidden */
  19354. _renderId: number;
  19355. /**
  19356. * Gets or sets the list of subMeshes
  19357. * @see http://doc.babylonjs.com/how_to/multi_materials
  19358. */
  19359. subMeshes: SubMesh[];
  19360. /** @hidden */
  19361. _submeshesOctree: Octree<SubMesh>;
  19362. /** @hidden */
  19363. _intersectionsInProgress: AbstractMesh[];
  19364. /** @hidden */
  19365. _unIndexed: boolean;
  19366. /** @hidden */
  19367. _lightSources: Light[];
  19368. /** @hidden */
  19369. readonly _positions: Nullable<Vector3[]>;
  19370. /** @hidden */
  19371. _waitingActions: any;
  19372. /** @hidden */
  19373. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19374. private _skeleton;
  19375. /** @hidden */
  19376. _bonesTransformMatrices: Nullable<Float32Array>;
  19377. /**
  19378. * Gets or sets a skeleton to apply skining transformations
  19379. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19380. */
  19381. skeleton: Nullable<Skeleton>;
  19382. /**
  19383. * Creates a new AbstractMesh
  19384. * @param name defines the name of the mesh
  19385. * @param scene defines the hosting scene
  19386. */
  19387. constructor(name: string, scene?: Nullable<Scene>);
  19388. /**
  19389. * Returns the string "AbstractMesh"
  19390. * @returns "AbstractMesh"
  19391. */
  19392. getClassName(): string;
  19393. /**
  19394. * Gets a string representation of the current mesh
  19395. * @param fullDetails defines a boolean indicating if full details must be included
  19396. * @returns a string representation of the current mesh
  19397. */
  19398. toString(fullDetails?: boolean): string;
  19399. /** @hidden */
  19400. _rebuild(): void;
  19401. /** @hidden */
  19402. _resyncLightSources(): void;
  19403. /** @hidden */
  19404. _resyncLighSource(light: Light): void;
  19405. /** @hidden */
  19406. _unBindEffect(): void;
  19407. /** @hidden */
  19408. _removeLightSource(light: Light): void;
  19409. private _markSubMeshesAsDirty;
  19410. /** @hidden */
  19411. _markSubMeshesAsLightDirty(): void;
  19412. /** @hidden */
  19413. _markSubMeshesAsAttributesDirty(): void;
  19414. /** @hidden */
  19415. _markSubMeshesAsMiscDirty(): void;
  19416. /**
  19417. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19418. */
  19419. scaling: Vector3;
  19420. /**
  19421. * Disables the mesh edge rendering mode
  19422. * @returns the currentAbstractMesh
  19423. */
  19424. disableEdgesRendering(): AbstractMesh;
  19425. /**
  19426. * Enables the edge rendering mode on the mesh.
  19427. * This mode makes the mesh edges visible
  19428. * @param epsilon defines the maximal distance between two angles to detect a face
  19429. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19430. * @returns the currentAbstractMesh
  19431. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19432. */
  19433. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19434. /**
  19435. * Gets the edgesRenderer associated with the mesh
  19436. */
  19437. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19438. /**
  19439. * Returns true if the mesh is blocked. Implemented by child classes
  19440. */
  19441. readonly isBlocked: boolean;
  19442. /**
  19443. * Returns the mesh itself by default. Implemented by child classes
  19444. * @param camera defines the camera to use to pick the right LOD level
  19445. * @returns the currentAbstractMesh
  19446. */
  19447. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19448. /**
  19449. * Returns 0 by default. Implemented by child classes
  19450. * @returns an integer
  19451. */
  19452. getTotalVertices(): number;
  19453. /**
  19454. * Returns null by default. Implemented by child classes
  19455. * @returns null
  19456. */
  19457. getIndices(): Nullable<IndicesArray>;
  19458. /**
  19459. * Returns the array of the requested vertex data kind. Implemented by child classes
  19460. * @param kind defines the vertex data kind to use
  19461. * @returns null
  19462. */
  19463. getVerticesData(kind: string): Nullable<FloatArray>;
  19464. /**
  19465. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19466. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19467. * Note that a new underlying VertexBuffer object is created each call.
  19468. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19469. * @param kind defines vertex data kind:
  19470. * * BABYLON.VertexBuffer.PositionKind
  19471. * * BABYLON.VertexBuffer.UVKind
  19472. * * BABYLON.VertexBuffer.UV2Kind
  19473. * * BABYLON.VertexBuffer.UV3Kind
  19474. * * BABYLON.VertexBuffer.UV4Kind
  19475. * * BABYLON.VertexBuffer.UV5Kind
  19476. * * BABYLON.VertexBuffer.UV6Kind
  19477. * * BABYLON.VertexBuffer.ColorKind
  19478. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19479. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19480. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19481. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19482. * @param data defines the data source
  19483. * @param updatable defines if the data must be flagged as updatable (or static)
  19484. * @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
  19485. * @returns the current mesh
  19486. */
  19487. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19488. /**
  19489. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19490. * If the mesh has no geometry, it is simply returned as it is.
  19491. * @param kind defines vertex data kind:
  19492. * * BABYLON.VertexBuffer.PositionKind
  19493. * * BABYLON.VertexBuffer.UVKind
  19494. * * BABYLON.VertexBuffer.UV2Kind
  19495. * * BABYLON.VertexBuffer.UV3Kind
  19496. * * BABYLON.VertexBuffer.UV4Kind
  19497. * * BABYLON.VertexBuffer.UV5Kind
  19498. * * BABYLON.VertexBuffer.UV6Kind
  19499. * * BABYLON.VertexBuffer.ColorKind
  19500. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19501. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19502. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19503. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19504. * @param data defines the data source
  19505. * @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
  19506. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19507. * @returns the current mesh
  19508. */
  19509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19510. /**
  19511. * Sets the mesh indices,
  19512. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19513. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19514. * @param totalVertices Defines the total number of vertices
  19515. * @returns the current mesh
  19516. */
  19517. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19518. /**
  19519. * Gets a boolean indicating if specific vertex data is present
  19520. * @param kind defines the vertex data kind to use
  19521. * @returns true is data kind is present
  19522. */
  19523. isVerticesDataPresent(kind: string): boolean;
  19524. /**
  19525. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19526. * @returns a BoundingInfo
  19527. */
  19528. getBoundingInfo(): BoundingInfo;
  19529. /**
  19530. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19531. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19532. * @returns the current mesh
  19533. */
  19534. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19535. /**
  19536. * Overwrite the current bounding info
  19537. * @param boundingInfo defines the new bounding info
  19538. * @returns the current mesh
  19539. */
  19540. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19541. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19542. readonly useBones: boolean;
  19543. /** @hidden */
  19544. _preActivate(): void;
  19545. /** @hidden */
  19546. _preActivateForIntermediateRendering(renderId: number): void;
  19547. /** @hidden */
  19548. _activate(renderId: number): void;
  19549. /**
  19550. * Gets the current world matrix
  19551. * @returns a Matrix
  19552. */
  19553. getWorldMatrix(): Matrix;
  19554. /** @hidden */
  19555. _getWorldMatrixDeterminant(): number;
  19556. /**
  19557. * Perform relative position change from the point of view of behind the front of the mesh.
  19558. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19559. * Supports definition of mesh facing forward or backward
  19560. * @param amountRight defines the distance on the right axis
  19561. * @param amountUp defines the distance on the up axis
  19562. * @param amountForward defines the distance on the forward axis
  19563. * @returns the current mesh
  19564. */
  19565. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19566. /**
  19567. * Calculate relative position change from the point of view of behind the front of the mesh.
  19568. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19569. * Supports definition of mesh facing forward or backward
  19570. * @param amountRight defines the distance on the right axis
  19571. * @param amountUp defines the distance on the up axis
  19572. * @param amountForward defines the distance on the forward axis
  19573. * @returns the new displacement vector
  19574. */
  19575. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19576. /**
  19577. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19578. * Supports definition of mesh facing forward or backward
  19579. * @param flipBack defines the flip
  19580. * @param twirlClockwise defines the twirl
  19581. * @param tiltRight defines the tilt
  19582. * @returns the current mesh
  19583. */
  19584. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19585. /**
  19586. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19587. * Supports definition of mesh facing forward or backward.
  19588. * @param flipBack defines the flip
  19589. * @param twirlClockwise defines the twirl
  19590. * @param tiltRight defines the tilt
  19591. * @returns the new rotation vector
  19592. */
  19593. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19594. /**
  19595. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19596. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19597. * @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
  19598. * @returns the new bounding vectors
  19599. */
  19600. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19601. min: Vector3;
  19602. max: Vector3;
  19603. };
  19604. /** @hidden */
  19605. _updateBoundingInfo(): AbstractMesh;
  19606. /** @hidden */
  19607. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19608. /** @hidden */
  19609. protected _afterComputeWorldMatrix(): void;
  19610. /**
  19611. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19612. * A mesh is in the frustum if its bounding box intersects the frustum
  19613. * @param frustumPlanes defines the frustum to test
  19614. * @returns true if the mesh is in the frustum planes
  19615. */
  19616. isInFrustum(frustumPlanes: Plane[]): boolean;
  19617. /**
  19618. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19619. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19620. * @param frustumPlanes defines the frustum to test
  19621. * @returns true if the mesh is completely in the frustum planes
  19622. */
  19623. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19624. /**
  19625. * True if the mesh intersects another mesh or a SolidParticle object
  19626. * @param mesh defines a target mesh or SolidParticle to test
  19627. * @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)
  19628. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19629. * @returns true if there is an intersection
  19630. */
  19631. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19632. /**
  19633. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19634. * @param point defines the point to test
  19635. * @returns true if there is an intersection
  19636. */
  19637. intersectsPoint(point: Vector3): boolean;
  19638. /**
  19639. * Gets the current physics impostor
  19640. * @see http://doc.babylonjs.com/features/physics_engine
  19641. * @returns a physics impostor or null
  19642. */
  19643. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19644. /**
  19645. * Gets the position of the current mesh in camera space
  19646. * @param camera defines the camera to use
  19647. * @returns a position
  19648. */
  19649. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19650. /**
  19651. * Returns the distance from the mesh to the active camera
  19652. * @param camera defines the camera to use
  19653. * @returns the distance
  19654. */
  19655. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19656. /**
  19657. * Apply a physic impulse to the mesh
  19658. * @param force defines the force to apply
  19659. * @param contactPoint defines where to apply the force
  19660. * @returns the current mesh
  19661. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19662. */
  19663. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19664. /**
  19665. * Creates a physic joint between two meshes
  19666. * @param otherMesh defines the other mesh to use
  19667. * @param pivot1 defines the pivot to use on this mesh
  19668. * @param pivot2 defines the pivot to use on the other mesh
  19669. * @param options defines additional options (can be plugin dependent)
  19670. * @returns the current mesh
  19671. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19672. */
  19673. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19674. /**
  19675. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19677. */
  19678. checkCollisions: boolean;
  19679. /**
  19680. * Gets Collider object used to compute collisions (not physics)
  19681. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19682. */
  19683. readonly collider: Collider;
  19684. /**
  19685. * Move the mesh using collision engine
  19686. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19687. * @param displacement defines the requested displacement vector
  19688. * @returns the current mesh
  19689. */
  19690. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19691. private _onCollisionPositionChange;
  19692. /**
  19693. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19694. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19695. * @param maxCapacity defines the maximum size of each block (64 by default)
  19696. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19697. * @returns the new octree
  19698. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19700. */
  19701. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19702. /** @hidden */
  19703. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19704. /** @hidden */
  19705. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19706. /** @hidden */
  19707. _checkCollision(collider: Collider): AbstractMesh;
  19708. /** @hidden */
  19709. _generatePointsArray(): boolean;
  19710. /**
  19711. * Checks if the passed Ray intersects with the mesh
  19712. * @param ray defines the ray to use
  19713. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19714. * @returns the picking info
  19715. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19716. */
  19717. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19718. /**
  19719. * Clones the current mesh
  19720. * @param name defines the mesh name
  19721. * @param newParent defines the new mesh parent
  19722. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19723. * @returns the new mesh
  19724. */
  19725. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19726. /**
  19727. * Disposes all the submeshes of the current meshnp
  19728. * @returns the current mesh
  19729. */
  19730. releaseSubMeshes(): AbstractMesh;
  19731. /**
  19732. * Releases resources associated with this abstract mesh.
  19733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19735. */
  19736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19737. /**
  19738. * Adds the passed mesh as a child to the current mesh
  19739. * @param mesh defines the child mesh
  19740. * @returns the current mesh
  19741. */
  19742. addChild(mesh: AbstractMesh): AbstractMesh;
  19743. /**
  19744. * Removes the passed mesh from the current mesh children list
  19745. * @param mesh defines the child mesh
  19746. * @returns the current mesh
  19747. */
  19748. removeChild(mesh: AbstractMesh): AbstractMesh;
  19749. /** @hidden */
  19750. private _initFacetData;
  19751. /**
  19752. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19753. * This method can be called within the render loop.
  19754. * 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
  19755. * @returns the current mesh
  19756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19757. */
  19758. updateFacetData(): AbstractMesh;
  19759. /**
  19760. * Returns the facetLocalNormals array.
  19761. * The normals are expressed in the mesh local spac
  19762. * @returns an array of Vector3
  19763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19764. */
  19765. getFacetLocalNormals(): Vector3[];
  19766. /**
  19767. * Returns the facetLocalPositions array.
  19768. * The facet positions are expressed in the mesh local space
  19769. * @returns an array of Vector3
  19770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19771. */
  19772. getFacetLocalPositions(): Vector3[];
  19773. /**
  19774. * Returns the facetLocalPartioning array
  19775. * @returns an array of array of numbers
  19776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19777. */
  19778. getFacetLocalPartitioning(): number[][];
  19779. /**
  19780. * Returns the i-th facet position in the world system.
  19781. * This method allocates a new Vector3 per call
  19782. * @param i defines the facet index
  19783. * @returns a new Vector3
  19784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19785. */
  19786. getFacetPosition(i: number): Vector3;
  19787. /**
  19788. * Sets the reference Vector3 with the i-th facet position in the world system
  19789. * @param i defines the facet index
  19790. * @param ref defines the target vector
  19791. * @returns the current mesh
  19792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19793. */
  19794. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19795. /**
  19796. * Returns the i-th facet normal in the world system.
  19797. * This method allocates a new Vector3 per call
  19798. * @param i defines the facet index
  19799. * @returns a new Vector3
  19800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19801. */
  19802. getFacetNormal(i: number): Vector3;
  19803. /**
  19804. * Sets the reference Vector3 with the i-th facet normal in the world system
  19805. * @param i defines the facet index
  19806. * @param ref defines the target vector
  19807. * @returns the current mesh
  19808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19809. */
  19810. getFacetNormalToRef(i: number, ref: Vector3): this;
  19811. /**
  19812. * 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)
  19813. * @param x defines x coordinate
  19814. * @param y defines y coordinate
  19815. * @param z defines z coordinate
  19816. * @returns the array of facet indexes
  19817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19818. */
  19819. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19820. /**
  19821. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19822. * @param projected sets as the (x,y,z) world projection on the facet
  19823. * @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
  19824. * @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
  19825. * @param x defines x coordinate
  19826. * @param y defines y coordinate
  19827. * @param z defines z coordinate
  19828. * @returns the face index if found (or null instead)
  19829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19830. */
  19831. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19832. /**
  19833. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19834. * @param projected sets as the (x,y,z) local projection on the facet
  19835. * @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
  19836. * @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
  19837. * @param x defines x coordinate
  19838. * @param y defines y coordinate
  19839. * @param z defines z coordinate
  19840. * @returns the face index if found (or null instead)
  19841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19842. */
  19843. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19844. /**
  19845. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19846. * @returns the parameters
  19847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19848. */
  19849. getFacetDataParameters(): any;
  19850. /**
  19851. * Disables the feature FacetData and frees the related memory
  19852. * @returns the current mesh
  19853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19854. */
  19855. disableFacetData(): AbstractMesh;
  19856. /**
  19857. * Updates the AbstractMesh indices array
  19858. * @param indices defines the data source
  19859. * @returns the current mesh
  19860. */
  19861. updateIndices(indices: IndicesArray): AbstractMesh;
  19862. /**
  19863. * Creates new normals data for the mesh
  19864. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19865. * @returns the current mesh
  19866. */
  19867. createNormals(updatable: boolean): AbstractMesh;
  19868. /**
  19869. * Align the mesh with a normal
  19870. * @param normal defines the normal to use
  19871. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19872. * @returns the current mesh
  19873. */
  19874. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19875. /** @hidden */
  19876. _checkOcclusionQuery(): void;
  19877. }
  19878. }
  19879. declare module BABYLON {
  19880. class Buffer {
  19881. private _engine;
  19882. private _buffer;
  19883. /** @hidden */
  19884. _data: Nullable<DataArray>;
  19885. private _updatable;
  19886. private _instanced;
  19887. /**
  19888. * Gets the byte stride.
  19889. */
  19890. readonly byteStride: number;
  19891. /**
  19892. * Constructor
  19893. * @param engine the engine
  19894. * @param data the data to use for this buffer
  19895. * @param updatable whether the data is updatable
  19896. * @param stride the stride (optional)
  19897. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19898. * @param instanced whether the buffer is instanced (optional)
  19899. * @param useBytes set to true if the stride in in bytes (optional)
  19900. */
  19901. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19902. /**
  19903. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19904. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19905. * @param offset defines offset in the buffer (0 by default)
  19906. * @param size defines the size in floats of attributes (position is 3 for instance)
  19907. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19908. * @param instanced defines if the vertex buffer contains indexed data
  19909. * @param useBytes defines if the offset and stride are in bytes
  19910. * @returns the new vertex buffer
  19911. */
  19912. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19913. isUpdatable(): boolean;
  19914. getData(): Nullable<DataArray>;
  19915. getBuffer(): Nullable<WebGLBuffer>;
  19916. /**
  19917. * Gets the stride in float32 units (i.e. byte stride / 4).
  19918. * May not be an integer if the byte stride is not divisible by 4.
  19919. * DEPRECATED. Use byteStride instead.
  19920. * @returns the stride in float32 units
  19921. */
  19922. getStrideSize(): number;
  19923. create(data?: Nullable<DataArray>): void;
  19924. _rebuild(): void;
  19925. update(data: DataArray): void;
  19926. /**
  19927. * Updates the data directly.
  19928. * @param data the new data
  19929. * @param offset the new offset
  19930. * @param vertexCount the vertex count (optional)
  19931. * @param useBytes set to true if the offset is in bytes
  19932. */
  19933. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19934. dispose(): void;
  19935. }
  19936. }
  19937. declare module BABYLON {
  19938. class CSG {
  19939. private polygons;
  19940. matrix: Matrix;
  19941. position: Vector3;
  19942. rotation: Vector3;
  19943. rotationQuaternion: Nullable<Quaternion>;
  19944. scaling: Vector3;
  19945. static FromMesh(mesh: Mesh): CSG;
  19946. private static FromPolygons;
  19947. clone(): CSG;
  19948. union(csg: CSG): CSG;
  19949. unionInPlace(csg: CSG): void;
  19950. subtract(csg: CSG): CSG;
  19951. subtractInPlace(csg: CSG): void;
  19952. intersect(csg: CSG): CSG;
  19953. intersectInPlace(csg: CSG): void;
  19954. inverse(): CSG;
  19955. inverseInPlace(): void;
  19956. copyTransformAttributes(csg: CSG): CSG;
  19957. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19958. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19959. }
  19960. }
  19961. declare module BABYLON {
  19962. /**
  19963. * Class used to store geometry data (vertex buffers + index buffer)
  19964. */
  19965. class Geometry implements IGetSetVerticesData {
  19966. /**
  19967. * Gets or sets the unique ID of the geometry
  19968. */
  19969. id: string;
  19970. /**
  19971. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19972. */
  19973. delayLoadState: number;
  19974. /**
  19975. * Gets the file containing the data to load when running in delay load state
  19976. */
  19977. delayLoadingFile: Nullable<string>;
  19978. /**
  19979. * Callback called when the geometry is updated
  19980. */
  19981. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19982. private _scene;
  19983. private _engine;
  19984. private _meshes;
  19985. private _totalVertices;
  19986. /** @hidden */
  19987. _indices: IndicesArray;
  19988. /** @hidden */
  19989. _vertexBuffers: {
  19990. [key: string]: VertexBuffer;
  19991. };
  19992. private _isDisposed;
  19993. private _extend;
  19994. private _boundingBias;
  19995. /** @hidden */
  19996. _delayInfo: Array<string>;
  19997. private _indexBuffer;
  19998. private _indexBufferIsUpdatable;
  19999. /** @hidden */
  20000. _boundingInfo: Nullable<BoundingInfo>;
  20001. /** @hidden */
  20002. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20003. /** @hidden */
  20004. _softwareSkinningRenderId: number;
  20005. private _vertexArrayObjects;
  20006. private _updatable;
  20007. /** @hidden */
  20008. _positions: Nullable<Vector3[]>;
  20009. /**
  20010. * 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
  20011. */
  20012. /**
  20013. * 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
  20014. */
  20015. boundingBias: Vector2;
  20016. /**
  20017. * Static function used to attach a new empty geometry to a mesh
  20018. * @param mesh defines the mesh to attach the geometry to
  20019. * @returns the new {BABYLON.Geometry}
  20020. */
  20021. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20022. /**
  20023. * Creates a new geometry
  20024. * @param id defines the unique ID
  20025. * @param scene defines the hosting scene
  20026. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20027. * @param updatable defines if geometry must be updatable (false by default)
  20028. * @param mesh defines the mesh that will be associated with the geometry
  20029. */
  20030. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20031. /**
  20032. * Gets the current extend of the geometry
  20033. */
  20034. readonly extend: {
  20035. minimum: Vector3;
  20036. maximum: Vector3;
  20037. };
  20038. /**
  20039. * Gets the hosting scene
  20040. * @returns the hosting {BABYLON.Scene}
  20041. */
  20042. getScene(): Scene;
  20043. /**
  20044. * Gets the hosting engine
  20045. * @returns the hosting {BABYLON.Engine}
  20046. */
  20047. getEngine(): Engine;
  20048. /**
  20049. * Defines if the geometry is ready to use
  20050. * @returns true if the geometry is ready to be used
  20051. */
  20052. isReady(): boolean;
  20053. /**
  20054. * Gets a value indicating that the geometry should not be serialized
  20055. */
  20056. readonly doNotSerialize: boolean;
  20057. /** @hidden */
  20058. _rebuild(): void;
  20059. /**
  20060. * Affects all geometry data in one call
  20061. * @param vertexData defines the geometry data
  20062. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20063. */
  20064. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20065. /**
  20066. * Set specific vertex data
  20067. * @param kind defines the data kind (Position, normal, etc...)
  20068. * @param data defines the vertex data to use
  20069. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20070. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20071. */
  20072. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20073. /**
  20074. * Removes a specific vertex data
  20075. * @param kind defines the data kind (Position, normal, etc...)
  20076. */
  20077. removeVerticesData(kind: string): void;
  20078. /**
  20079. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20080. * @param buffer defines the vertex buffer to use
  20081. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20082. */
  20083. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20084. /**
  20085. * Update a specific vertex buffer
  20086. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20087. * It will do nothing if the buffer is not updatable
  20088. * @param kind defines the data kind (Position, normal, etc...)
  20089. * @param data defines the data to use
  20090. * @param offset defines the offset in the target buffer where to store the data
  20091. * @param useBytes set to true if the offset is in bytes
  20092. */
  20093. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20094. /**
  20095. * Update a specific vertex buffer
  20096. * This function will create a new buffer if the current one is not updatable
  20097. * @param kind defines the data kind (Position, normal, etc...)
  20098. * @param data defines the data to use
  20099. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20100. */
  20101. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20102. private _updateBoundingInfo;
  20103. /** @hidden */
  20104. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20105. /**
  20106. * Gets total number of vertices
  20107. * @returns the total number of vertices
  20108. */
  20109. getTotalVertices(): number;
  20110. /**
  20111. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20112. * @param kind defines the data kind (Position, normal, etc...)
  20113. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20114. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20115. * @returns a float array containing vertex data
  20116. */
  20117. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20118. /**
  20119. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20120. * @param kind defines the data kind (Position, normal, etc...)
  20121. * @returns true if the vertex buffer with the specified kind is updatable
  20122. */
  20123. isVertexBufferUpdatable(kind: string): boolean;
  20124. /**
  20125. * Gets a specific vertex buffer
  20126. * @param kind defines the data kind (Position, normal, etc...)
  20127. * @returns a {BABYLON.VertexBuffer}
  20128. */
  20129. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20130. /**
  20131. * Returns all vertex buffers
  20132. * @return an object holding all vertex buffers indexed by kind
  20133. */
  20134. getVertexBuffers(): Nullable<{
  20135. [key: string]: VertexBuffer;
  20136. }>;
  20137. /**
  20138. * Gets a boolean indicating if specific vertex buffer is present
  20139. * @param kind defines the data kind (Position, normal, etc...)
  20140. * @returns true if data is present
  20141. */
  20142. isVerticesDataPresent(kind: string): boolean;
  20143. /**
  20144. * Gets a list of all attached data kinds (Position, normal, etc...)
  20145. * @returns a list of string containing all kinds
  20146. */
  20147. getVerticesDataKinds(): string[];
  20148. /**
  20149. * Update index buffer
  20150. * @param indices defines the indices to store in the index buffer
  20151. * @param offset defines the offset in the target buffer where to store the data
  20152. */
  20153. updateIndices(indices: IndicesArray, offset?: number): void;
  20154. /**
  20155. * Creates a new index buffer
  20156. * @param indices defines the indices to store in the index buffer
  20157. * @param totalVertices defines the total number of vertices (could be null)
  20158. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20159. */
  20160. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20161. /**
  20162. * Return the total number of indices
  20163. * @returns the total number of indices
  20164. */
  20165. getTotalIndices(): number;
  20166. /**
  20167. * Gets the index buffer array
  20168. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20169. * @returns the index buffer array
  20170. */
  20171. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20172. /**
  20173. * Gets the index buffer
  20174. * @return the index buffer
  20175. */
  20176. getIndexBuffer(): Nullable<WebGLBuffer>;
  20177. /** @hidden */
  20178. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20179. /**
  20180. * Release the associated resources for a specific mesh
  20181. * @param mesh defines the source mesh
  20182. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20183. */
  20184. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20185. /**
  20186. * Apply current geometry to a given mesh
  20187. * @param mesh defines the mesh to apply geometry to
  20188. */
  20189. applyToMesh(mesh: Mesh): void;
  20190. private _updateExtend;
  20191. private _applyToMesh;
  20192. private notifyUpdate;
  20193. /**
  20194. * Load the geometry if it was flagged as delay loaded
  20195. * @param scene defines the hosting scene
  20196. * @param onLoaded defines a callback called when the geometry is loaded
  20197. */
  20198. load(scene: Scene, onLoaded?: () => void): void;
  20199. private _queueLoad;
  20200. /**
  20201. * Invert the geometry to move from a right handed system to a left handed one.
  20202. */
  20203. toLeftHanded(): void;
  20204. /** @hidden */
  20205. _resetPointsArrayCache(): void;
  20206. /** @hidden */
  20207. _generatePointsArray(): boolean;
  20208. /**
  20209. * Gets a value indicating if the geometry is disposed
  20210. * @returns true if the geometry was disposed
  20211. */
  20212. isDisposed(): boolean;
  20213. private _disposeVertexArrayObjects;
  20214. /**
  20215. * Free all associated resources
  20216. */
  20217. dispose(): void;
  20218. /**
  20219. * Clone the current geometry into a new geometry
  20220. * @param id defines the unique ID of the new geometry
  20221. * @returns a new geometry object
  20222. */
  20223. copy(id: string): Geometry;
  20224. /**
  20225. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20226. * @return a JSON representation of the current geometry data (without the vertices data)
  20227. */
  20228. serialize(): any;
  20229. private toNumberArray;
  20230. /**
  20231. * Serialize all vertices data into a JSON oject
  20232. * @returns a JSON representation of the current geometry data
  20233. */
  20234. serializeVerticeData(): any;
  20235. /**
  20236. * Extracts a clone of a mesh geometry
  20237. * @param mesh defines the source mesh
  20238. * @param id defines the unique ID of the new geometry object
  20239. * @returns the new geometry object
  20240. */
  20241. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20242. /**
  20243. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20244. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20245. * Be aware Math.random() could cause collisions, but:
  20246. * "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"
  20247. * @returns a string containing a new GUID
  20248. */
  20249. static RandomId(): string;
  20250. /** @hidden */
  20251. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20252. private static _CleanMatricesWeights;
  20253. /**
  20254. * Create a new geometry from persisted data (Using .babylon file format)
  20255. * @param parsedVertexData defines the persisted data
  20256. * @param scene defines the hosting scene
  20257. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20258. * @returns the new geometry object
  20259. */
  20260. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20261. }
  20262. /**
  20263. * Abstract class used to provide common services for all typed geometries
  20264. * @hidden
  20265. */
  20266. class _PrimitiveGeometry extends Geometry {
  20267. private _canBeRegenerated;
  20268. private _beingRegenerated;
  20269. /**
  20270. * Creates a new typed geometry
  20271. * @param id defines the unique ID of the geometry
  20272. * @param scene defines the hosting scene
  20273. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20274. * @param mesh defines the hosting mesh (can be null)
  20275. */
  20276. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20277. /**
  20278. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20279. * @returns true if the geometry can be regenerated
  20280. */
  20281. canBeRegenerated(): boolean;
  20282. /**
  20283. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20284. */
  20285. regenerate(): void;
  20286. /**
  20287. * Clone the geometry
  20288. * @param id defines the unique ID of the new geometry
  20289. * @returns the new geometry
  20290. */
  20291. asNewGeometry(id: string): Geometry;
  20292. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20293. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20294. /** @hidden */
  20295. _regenerateVertexData(): VertexData;
  20296. copy(id: string): Geometry;
  20297. serialize(): any;
  20298. }
  20299. /**
  20300. * Creates a ribbon geometry
  20301. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20302. */
  20303. class RibbonGeometry extends _PrimitiveGeometry {
  20304. /**
  20305. * Defines the array of paths to use
  20306. */
  20307. pathArray: Vector3[][];
  20308. /**
  20309. * Defines if the last and first points of each path in your pathArray must be joined
  20310. */
  20311. closeArray: boolean;
  20312. /**
  20313. * Defines if the last and first points of each path in your pathArray must be joined
  20314. */
  20315. closePath: boolean;
  20316. /**
  20317. * Defines the offset between points
  20318. */
  20319. offset: number;
  20320. /**
  20321. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20322. */
  20323. side: number;
  20324. /**
  20325. * Creates a ribbon geometry
  20326. * @param id defines the unique ID of the geometry
  20327. * @param scene defines the hosting scene
  20328. * @param pathArray defines the array of paths to use
  20329. * @param closeArray defines if the last path and the first path must be joined
  20330. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20331. * @param offset defines the offset between points
  20332. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20333. * @param mesh defines the hosting mesh (can be null)
  20334. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20335. */
  20336. constructor(id: string, scene: Scene,
  20337. /**
  20338. * Defines the array of paths to use
  20339. */
  20340. pathArray: Vector3[][],
  20341. /**
  20342. * Defines if the last and first points of each path in your pathArray must be joined
  20343. */
  20344. closeArray: boolean,
  20345. /**
  20346. * Defines if the last and first points of each path in your pathArray must be joined
  20347. */
  20348. closePath: boolean,
  20349. /**
  20350. * Defines the offset between points
  20351. */
  20352. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20353. /**
  20354. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20355. */
  20356. side?: number);
  20357. /** @hidden */
  20358. _regenerateVertexData(): VertexData;
  20359. copy(id: string): Geometry;
  20360. }
  20361. /**
  20362. * Creates a box geometry
  20363. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20364. */
  20365. class BoxGeometry extends _PrimitiveGeometry {
  20366. /**
  20367. * Defines the zise of the box (width, height and depth are the same)
  20368. */
  20369. size: number;
  20370. /**
  20371. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20372. */
  20373. side: number;
  20374. /**
  20375. * Creates a box geometry
  20376. * @param id defines the unique ID of the geometry
  20377. * @param scene defines the hosting scene
  20378. * @param size defines the zise of the box (width, height and depth are the same)
  20379. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20380. * @param mesh defines the hosting mesh (can be null)
  20381. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20382. */
  20383. constructor(id: string, scene: Scene,
  20384. /**
  20385. * Defines the zise of the box (width, height and depth are the same)
  20386. */
  20387. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20388. /**
  20389. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20390. */
  20391. side?: number);
  20392. _regenerateVertexData(): VertexData;
  20393. copy(id: string): Geometry;
  20394. serialize(): any;
  20395. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20396. }
  20397. /**
  20398. * Creates a sphere geometry
  20399. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20400. */
  20401. class SphereGeometry extends _PrimitiveGeometry {
  20402. /**
  20403. * Defines the number of segments to use to create the sphere
  20404. */
  20405. segments: number;
  20406. /**
  20407. * Defines the diameter of the sphere
  20408. */
  20409. diameter: number;
  20410. /**
  20411. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20412. */
  20413. side: number;
  20414. /**
  20415. * Create a new sphere geometry
  20416. * @param id defines the unique ID of the geometry
  20417. * @param scene defines the hosting scene
  20418. * @param segments defines the number of segments to use to create the sphere
  20419. * @param diameter defines the diameter of the sphere
  20420. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20421. * @param mesh defines the hosting mesh (can be null)
  20422. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20423. */
  20424. constructor(id: string, scene: Scene,
  20425. /**
  20426. * Defines the number of segments to use to create the sphere
  20427. */
  20428. segments: number,
  20429. /**
  20430. * Defines the diameter of the sphere
  20431. */
  20432. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20433. /**
  20434. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20435. */
  20436. side?: number);
  20437. _regenerateVertexData(): VertexData;
  20438. copy(id: string): Geometry;
  20439. serialize(): any;
  20440. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20441. }
  20442. /**
  20443. * Creates a disc geometry
  20444. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20445. */
  20446. class DiscGeometry extends _PrimitiveGeometry {
  20447. /**
  20448. * Defines the radius of the disc
  20449. */
  20450. radius: number;
  20451. /**
  20452. * Defines the tesselation factor to apply to the disc
  20453. */
  20454. tessellation: number;
  20455. /**
  20456. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20457. */
  20458. side: number;
  20459. /**
  20460. * Creates a new disc geometry
  20461. * @param id defines the unique ID of the geometry
  20462. * @param scene defines the hosting scene
  20463. * @param radius defines the radius of the disc
  20464. * @param tessellation defines the tesselation factor to apply to the disc
  20465. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20466. * @param mesh defines the hosting mesh (can be null)
  20467. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20468. */
  20469. constructor(id: string, scene: Scene,
  20470. /**
  20471. * Defines the radius of the disc
  20472. */
  20473. radius: number,
  20474. /**
  20475. * Defines the tesselation factor to apply to the disc
  20476. */
  20477. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20478. /**
  20479. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20480. */
  20481. side?: number);
  20482. _regenerateVertexData(): VertexData;
  20483. copy(id: string): Geometry;
  20484. }
  20485. /**
  20486. * Creates a new cylinder geometry
  20487. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20488. */
  20489. class CylinderGeometry extends _PrimitiveGeometry {
  20490. /**
  20491. * Defines the height of the cylinder
  20492. */
  20493. height: number;
  20494. /**
  20495. * Defines the diameter of the cylinder's top cap
  20496. */
  20497. diameterTop: number;
  20498. /**
  20499. * Defines the diameter of the cylinder's bottom cap
  20500. */
  20501. diameterBottom: number;
  20502. /**
  20503. * Defines the tessellation factor to apply to the cylinder
  20504. */
  20505. tessellation: number;
  20506. /**
  20507. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20508. */
  20509. subdivisions: number;
  20510. /**
  20511. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20512. */
  20513. side: number;
  20514. /**
  20515. * Creates a new cylinder geometry
  20516. * @param id defines the unique ID of the geometry
  20517. * @param scene defines the hosting scene
  20518. * @param height defines the height of the cylinder
  20519. * @param diameterTop defines the diameter of the cylinder's top cap
  20520. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20521. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20522. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20523. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20524. * @param mesh defines the hosting mesh (can be null)
  20525. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20526. */
  20527. constructor(id: string, scene: Scene,
  20528. /**
  20529. * Defines the height of the cylinder
  20530. */
  20531. height: number,
  20532. /**
  20533. * Defines the diameter of the cylinder's top cap
  20534. */
  20535. diameterTop: number,
  20536. /**
  20537. * Defines the diameter of the cylinder's bottom cap
  20538. */
  20539. diameterBottom: number,
  20540. /**
  20541. * Defines the tessellation factor to apply to the cylinder
  20542. */
  20543. tessellation: number,
  20544. /**
  20545. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20546. */
  20547. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20548. /**
  20549. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20550. */
  20551. side?: number);
  20552. _regenerateVertexData(): VertexData;
  20553. copy(id: string): Geometry;
  20554. serialize(): any;
  20555. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20556. }
  20557. /**
  20558. * Creates a new torus geometry
  20559. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20560. */
  20561. class TorusGeometry extends _PrimitiveGeometry {
  20562. /**
  20563. * Defines the diameter of the torus
  20564. */
  20565. diameter: number;
  20566. /**
  20567. * Defines the thickness of the torus (ie. internal diameter)
  20568. */
  20569. thickness: number;
  20570. /**
  20571. * Defines the tesselation factor to apply to the torus
  20572. */
  20573. tessellation: number;
  20574. /**
  20575. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20576. */
  20577. side: number;
  20578. /**
  20579. * Creates a new torus geometry
  20580. * @param id defines the unique ID of the geometry
  20581. * @param scene defines the hosting scene
  20582. * @param diameter defines the diameter of the torus
  20583. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20584. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20585. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20586. * @param mesh defines the hosting mesh (can be null)
  20587. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20588. */
  20589. constructor(id: string, scene: Scene,
  20590. /**
  20591. * Defines the diameter of the torus
  20592. */
  20593. diameter: number,
  20594. /**
  20595. * Defines the thickness of the torus (ie. internal diameter)
  20596. */
  20597. thickness: number,
  20598. /**
  20599. * Defines the tesselation factor to apply to the torus
  20600. */
  20601. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20602. /**
  20603. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20604. */
  20605. side?: number);
  20606. _regenerateVertexData(): VertexData;
  20607. copy(id: string): Geometry;
  20608. serialize(): any;
  20609. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20610. }
  20611. /**
  20612. * Creates a new ground geometry
  20613. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20614. */
  20615. class GroundGeometry extends _PrimitiveGeometry {
  20616. /**
  20617. * Defines the width of the ground
  20618. */
  20619. width: number;
  20620. /**
  20621. * Defines the height of the ground
  20622. */
  20623. height: number;
  20624. /**
  20625. * Defines the subdivisions to apply to the ground
  20626. */
  20627. subdivisions: number;
  20628. /**
  20629. * Creates a new ground geometry
  20630. * @param id defines the unique ID of the geometry
  20631. * @param scene defines the hosting scene
  20632. * @param width defines the width of the ground
  20633. * @param height defines the height of the ground
  20634. * @param subdivisions defines the subdivisions to apply to the ground
  20635. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20636. * @param mesh defines the hosting mesh (can be null)
  20637. */
  20638. constructor(id: string, scene: Scene,
  20639. /**
  20640. * Defines the width of the ground
  20641. */
  20642. width: number,
  20643. /**
  20644. * Defines the height of the ground
  20645. */
  20646. height: number,
  20647. /**
  20648. * Defines the subdivisions to apply to the ground
  20649. */
  20650. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20651. _regenerateVertexData(): VertexData;
  20652. copy(id: string): Geometry;
  20653. serialize(): any;
  20654. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20655. }
  20656. /**
  20657. * Creates a tiled ground geometry
  20658. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20659. */
  20660. class TiledGroundGeometry extends _PrimitiveGeometry {
  20661. /**
  20662. * Defines the minimum value on X axis
  20663. */
  20664. xmin: number;
  20665. /**
  20666. * Defines the minimum value on Z axis
  20667. */
  20668. zmin: number;
  20669. /**
  20670. * Defines the maximum value on X axis
  20671. */
  20672. xmax: number;
  20673. /**
  20674. * Defines the maximum value on Z axis
  20675. */
  20676. zmax: number;
  20677. /**
  20678. * Defines the subdivisions to apply to the ground
  20679. */
  20680. subdivisions: {
  20681. w: number;
  20682. h: number;
  20683. };
  20684. /**
  20685. * Defines the precision to use when computing the tiles
  20686. */
  20687. precision: {
  20688. w: number;
  20689. h: number;
  20690. };
  20691. /**
  20692. * Creates a tiled ground geometry
  20693. * @param id defines the unique ID of the geometry
  20694. * @param scene defines the hosting scene
  20695. * @param xmin defines the minimum value on X axis
  20696. * @param zmin defines the minimum value on Z axis
  20697. * @param xmax defines the maximum value on X axis
  20698. * @param zmax defines the maximum value on Z axis
  20699. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20700. * @param precision defines the precision to use when computing the tiles
  20701. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20702. * @param mesh defines the hosting mesh (can be null)
  20703. */
  20704. constructor(id: string, scene: Scene,
  20705. /**
  20706. * Defines the minimum value on X axis
  20707. */
  20708. xmin: number,
  20709. /**
  20710. * Defines the minimum value on Z axis
  20711. */
  20712. zmin: number,
  20713. /**
  20714. * Defines the maximum value on X axis
  20715. */
  20716. xmax: number,
  20717. /**
  20718. * Defines the maximum value on Z axis
  20719. */
  20720. zmax: number,
  20721. /**
  20722. * Defines the subdivisions to apply to the ground
  20723. */
  20724. subdivisions: {
  20725. w: number;
  20726. h: number;
  20727. },
  20728. /**
  20729. * Defines the precision to use when computing the tiles
  20730. */
  20731. precision: {
  20732. w: number;
  20733. h: number;
  20734. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20735. _regenerateVertexData(): VertexData;
  20736. copy(id: string): Geometry;
  20737. }
  20738. /**
  20739. * Creates a plane geometry
  20740. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20741. */
  20742. class PlaneGeometry extends _PrimitiveGeometry {
  20743. /**
  20744. * Defines the size of the plane (width === height)
  20745. */
  20746. size: number;
  20747. /**
  20748. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20749. */
  20750. side: number;
  20751. /**
  20752. * Creates a plane geometry
  20753. * @param id defines the unique ID of the geometry
  20754. * @param scene defines the hosting scene
  20755. * @param size defines the size of the plane (width === height)
  20756. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20757. * @param mesh defines the hosting mesh (can be null)
  20758. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20759. */
  20760. constructor(id: string, scene: Scene,
  20761. /**
  20762. * Defines the size of the plane (width === height)
  20763. */
  20764. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20765. /**
  20766. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20767. */
  20768. side?: number);
  20769. _regenerateVertexData(): VertexData;
  20770. copy(id: string): Geometry;
  20771. serialize(): any;
  20772. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20773. }
  20774. /**
  20775. * Creates a torus knot geometry
  20776. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20777. */
  20778. class TorusKnotGeometry extends _PrimitiveGeometry {
  20779. /**
  20780. * Defines the radius of the torus knot
  20781. */
  20782. radius: number;
  20783. /**
  20784. * Defines the thickness of the torus knot tube
  20785. */
  20786. tube: number;
  20787. /**
  20788. * Defines the number of radial segments
  20789. */
  20790. radialSegments: number;
  20791. /**
  20792. * Defines the number of tubular segments
  20793. */
  20794. tubularSegments: number;
  20795. /**
  20796. * Defines the first number of windings
  20797. */
  20798. p: number;
  20799. /**
  20800. * Defines the second number of windings
  20801. */
  20802. q: number;
  20803. /**
  20804. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20805. */
  20806. side: number;
  20807. /**
  20808. * Creates a torus knot geometry
  20809. * @param id defines the unique ID of the geometry
  20810. * @param scene defines the hosting scene
  20811. * @param radius defines the radius of the torus knot
  20812. * @param tube defines the thickness of the torus knot tube
  20813. * @param radialSegments defines the number of radial segments
  20814. * @param tubularSegments defines the number of tubular segments
  20815. * @param p defines the first number of windings
  20816. * @param q defines the second number of windings
  20817. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20818. * @param mesh defines the hosting mesh (can be null)
  20819. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20820. */
  20821. constructor(id: string, scene: Scene,
  20822. /**
  20823. * Defines the radius of the torus knot
  20824. */
  20825. radius: number,
  20826. /**
  20827. * Defines the thickness of the torus knot tube
  20828. */
  20829. tube: number,
  20830. /**
  20831. * Defines the number of radial segments
  20832. */
  20833. radialSegments: number,
  20834. /**
  20835. * Defines the number of tubular segments
  20836. */
  20837. tubularSegments: number,
  20838. /**
  20839. * Defines the first number of windings
  20840. */
  20841. p: number,
  20842. /**
  20843. * Defines the second number of windings
  20844. */
  20845. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20846. /**
  20847. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20848. */
  20849. side?: number);
  20850. _regenerateVertexData(): VertexData;
  20851. copy(id: string): Geometry;
  20852. serialize(): any;
  20853. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20854. }
  20855. }
  20856. declare module BABYLON {
  20857. class GroundMesh extends Mesh {
  20858. generateOctree: boolean;
  20859. private _heightQuads;
  20860. _subdivisionsX: number;
  20861. _subdivisionsY: number;
  20862. _width: number;
  20863. _height: number;
  20864. _minX: number;
  20865. _maxX: number;
  20866. _minZ: number;
  20867. _maxZ: number;
  20868. constructor(name: string, scene: Scene);
  20869. getClassName(): string;
  20870. readonly subdivisions: number;
  20871. readonly subdivisionsX: number;
  20872. readonly subdivisionsY: number;
  20873. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20874. /**
  20875. * Returns a height (y) value in the Worl system :
  20876. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20877. * Returns the ground y position if (x, z) are outside the ground surface.
  20878. */
  20879. getHeightAtCoordinates(x: number, z: number): number;
  20880. /**
  20881. * Returns a normalized vector (Vector3) orthogonal to the ground
  20882. * at the ground coordinates (x, z) expressed in the World system.
  20883. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20884. */
  20885. getNormalAtCoordinates(x: number, z: number): Vector3;
  20886. /**
  20887. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20888. * at the ground coordinates (x, z) expressed in the World system.
  20889. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20890. * Returns the GroundMesh.
  20891. */
  20892. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20893. /**
  20894. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20895. * if the ground has been updated.
  20896. * This can be used in the render loop.
  20897. * Returns the GroundMesh.
  20898. */
  20899. updateCoordinateHeights(): GroundMesh;
  20900. private _getFacetAt;
  20901. private _initHeightQuads;
  20902. private _computeHeightQuads;
  20903. serialize(serializationObject: any): void;
  20904. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20905. }
  20906. }
  20907. declare module BABYLON {
  20908. /**
  20909. * Creates an instance based on a source mesh.
  20910. */
  20911. class InstancedMesh extends AbstractMesh {
  20912. private _sourceMesh;
  20913. private _currentLOD;
  20914. constructor(name: string, source: Mesh);
  20915. /**
  20916. * Returns the string "InstancedMesh".
  20917. */
  20918. getClassName(): string;
  20919. readonly receiveShadows: boolean;
  20920. readonly material: Nullable<Material>;
  20921. readonly visibility: number;
  20922. readonly skeleton: Nullable<Skeleton>;
  20923. renderingGroupId: number;
  20924. /**
  20925. * Returns the total number of vertices (integer).
  20926. */
  20927. getTotalVertices(): number;
  20928. readonly sourceMesh: Mesh;
  20929. /**
  20930. * Is this node ready to be used/rendered
  20931. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20932. * @return {boolean} is it ready
  20933. */
  20934. isReady(completeCheck?: boolean): boolean;
  20935. /**
  20936. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20937. */
  20938. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20939. /**
  20940. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20941. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20942. * The `data` are either a numeric array either a Float32Array.
  20943. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20944. * 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).
  20945. * Note that a new underlying VertexBuffer object is created each call.
  20946. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20947. *
  20948. * Possible `kind` values :
  20949. * - BABYLON.VertexBuffer.PositionKind
  20950. * - BABYLON.VertexBuffer.UVKind
  20951. * - BABYLON.VertexBuffer.UV2Kind
  20952. * - BABYLON.VertexBuffer.UV3Kind
  20953. * - BABYLON.VertexBuffer.UV4Kind
  20954. * - BABYLON.VertexBuffer.UV5Kind
  20955. * - BABYLON.VertexBuffer.UV6Kind
  20956. * - BABYLON.VertexBuffer.ColorKind
  20957. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20958. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20959. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20960. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20961. *
  20962. * Returns the Mesh.
  20963. */
  20964. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20965. /**
  20966. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20967. * If the mesh has no geometry, it is simply returned as it is.
  20968. * The `data` are either a numeric array either a Float32Array.
  20969. * No new underlying VertexBuffer object is created.
  20970. * 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.
  20971. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20972. *
  20973. * Possible `kind` values :
  20974. * - BABYLON.VertexBuffer.PositionKind
  20975. * - BABYLON.VertexBuffer.UVKind
  20976. * - BABYLON.VertexBuffer.UV2Kind
  20977. * - BABYLON.VertexBuffer.UV3Kind
  20978. * - BABYLON.VertexBuffer.UV4Kind
  20979. * - BABYLON.VertexBuffer.UV5Kind
  20980. * - BABYLON.VertexBuffer.UV6Kind
  20981. * - BABYLON.VertexBuffer.ColorKind
  20982. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20983. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20984. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20985. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20986. *
  20987. * Returns the Mesh.
  20988. */
  20989. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20990. /**
  20991. * Sets the mesh indices.
  20992. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20993. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20994. * This method creates a new index buffer each call.
  20995. * Returns the Mesh.
  20996. */
  20997. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20998. /**
  20999. * Boolean : True if the mesh owns the requested kind of data.
  21000. */
  21001. isVerticesDataPresent(kind: string): boolean;
  21002. /**
  21003. * Returns an array of indices (IndicesArray).
  21004. */
  21005. getIndices(): Nullable<IndicesArray>;
  21006. readonly _positions: Nullable<Vector3[]>;
  21007. /**
  21008. * Sets a new updated BoundingInfo to the mesh.
  21009. * Returns the mesh.
  21010. */
  21011. refreshBoundingInfo(): InstancedMesh;
  21012. _preActivate(): InstancedMesh;
  21013. _activate(renderId: number): InstancedMesh;
  21014. /**
  21015. * Returns the current associated LOD AbstractMesh.
  21016. */
  21017. getLOD(camera: Camera): AbstractMesh;
  21018. _syncSubMeshes(): InstancedMesh;
  21019. _generatePointsArray(): boolean;
  21020. /**
  21021. * Creates a new InstancedMesh from the current mesh.
  21022. * - name (string) : the cloned mesh name
  21023. * - newParent (optional Node) : the optional Node to parent the clone to.
  21024. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21025. *
  21026. * Returns the clone.
  21027. */
  21028. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21029. /**
  21030. * Disposes the InstancedMesh.
  21031. * Returns nothing.
  21032. */
  21033. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21034. }
  21035. }
  21036. declare module BABYLON {
  21037. class LinesMesh extends Mesh {
  21038. useVertexColor?: boolean | undefined;
  21039. useVertexAlpha?: boolean | undefined;
  21040. color: Color3;
  21041. alpha: number;
  21042. /**
  21043. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21044. * This margin is expressed in world space coordinates, so its value may vary.
  21045. * Default value is 0.1
  21046. * @returns the intersection Threshold value.
  21047. */
  21048. /**
  21049. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21050. * This margin is expressed in world space coordinates, so its value may vary.
  21051. * @param value the new threshold to apply
  21052. */
  21053. intersectionThreshold: number;
  21054. private _intersectionThreshold;
  21055. private _colorShader;
  21056. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21057. /**
  21058. * Returns the string "LineMesh"
  21059. */
  21060. getClassName(): string;
  21061. /**
  21062. * @hidden
  21063. */
  21064. /**
  21065. * @hidden
  21066. */
  21067. material: Material;
  21068. /**
  21069. * @hidden
  21070. */
  21071. readonly checkCollisions: boolean;
  21072. createInstance(name: string): InstancedMesh;
  21073. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21074. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21075. dispose(doNotRecurse?: boolean): void;
  21076. /**
  21077. * Returns a new LineMesh object cloned from the current one.
  21078. */
  21079. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21080. }
  21081. }
  21082. declare module BABYLON {
  21083. /**
  21084. * @hidden
  21085. **/
  21086. class _InstancesBatch {
  21087. mustReturn: boolean;
  21088. visibleInstances: Nullable<InstancedMesh[]>[];
  21089. renderSelf: boolean[];
  21090. }
  21091. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21092. static _FRONTSIDE: number;
  21093. static _BACKSIDE: number;
  21094. static _DOUBLESIDE: number;
  21095. static _DEFAULTSIDE: number;
  21096. static _NO_CAP: number;
  21097. static _CAP_START: number;
  21098. static _CAP_END: number;
  21099. static _CAP_ALL: number;
  21100. /**
  21101. * Mesh side orientation : usually the external or front surface
  21102. */
  21103. static readonly FRONTSIDE: number;
  21104. /**
  21105. * Mesh side orientation : usually the internal or back surface
  21106. */
  21107. static readonly BACKSIDE: number;
  21108. /**
  21109. * Mesh side orientation : both internal and external or front and back surfaces
  21110. */
  21111. static readonly DOUBLESIDE: number;
  21112. /**
  21113. * Mesh side orientation : by default, `FRONTSIDE`
  21114. */
  21115. static readonly DEFAULTSIDE: number;
  21116. /**
  21117. * Mesh cap setting : no cap
  21118. */
  21119. static readonly NO_CAP: number;
  21120. /**
  21121. * Mesh cap setting : one cap at the beginning of the mesh
  21122. */
  21123. static readonly CAP_START: number;
  21124. /**
  21125. * Mesh cap setting : one cap at the end of the mesh
  21126. */
  21127. static readonly CAP_END: number;
  21128. /**
  21129. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21130. */
  21131. static readonly CAP_ALL: number;
  21132. private _onBeforeRenderObservable;
  21133. private _onAfterRenderObservable;
  21134. private _onBeforeDrawObservable;
  21135. /**
  21136. * An event triggered before rendering the mesh
  21137. */
  21138. readonly onBeforeRenderObservable: Observable<Mesh>;
  21139. /**
  21140. * An event triggered after rendering the mesh
  21141. */
  21142. readonly onAfterRenderObservable: Observable<Mesh>;
  21143. /**
  21144. * An event triggered before drawing the mesh
  21145. */
  21146. readonly onBeforeDrawObservable: Observable<Mesh>;
  21147. private _onBeforeDrawObserver;
  21148. onBeforeDraw: () => void;
  21149. delayLoadState: number;
  21150. instances: InstancedMesh[];
  21151. delayLoadingFile: string;
  21152. _binaryInfo: any;
  21153. private _LODLevels;
  21154. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21155. private _morphTargetManager;
  21156. morphTargetManager: Nullable<MorphTargetManager>;
  21157. _geometry: Nullable<Geometry>;
  21158. _delayInfo: Array<string>;
  21159. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21160. _visibleInstances: any;
  21161. private _renderIdForInstances;
  21162. private _batchCache;
  21163. private _instancesBufferSize;
  21164. private _instancesBuffer;
  21165. private _instancesData;
  21166. private _overridenInstanceCount;
  21167. private _effectiveMaterial;
  21168. _shouldGenerateFlatShading: boolean;
  21169. private _preActivateId;
  21170. _originalBuilderSideOrientation: number;
  21171. overrideMaterialSideOrientation: Nullable<number>;
  21172. private _areNormalsFrozen;
  21173. private _sourcePositions;
  21174. private _sourceNormals;
  21175. private _source;
  21176. readonly source: Nullable<Mesh>;
  21177. isUnIndexed: boolean;
  21178. /**
  21179. * @constructor
  21180. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21181. * @param {Scene} scene The scene to add this mesh to.
  21182. * @param {Node} parent The parent of this mesh, if it has one
  21183. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21184. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21185. * When false, achieved by calling a clone(), also passing False.
  21186. * This will make creation of children, recursive.
  21187. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21188. */
  21189. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21190. /**
  21191. * Returns the string "Mesh".
  21192. */
  21193. getClassName(): string;
  21194. /**
  21195. * Returns a string.
  21196. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21197. */
  21198. toString(fullDetails?: boolean): string;
  21199. _unBindEffect(): void;
  21200. /**
  21201. * True if the mesh has some Levels Of Details (LOD).
  21202. * Returns a boolean.
  21203. */
  21204. readonly hasLODLevels: boolean;
  21205. /**
  21206. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21207. * @returns an array of {BABYLON.MeshLODLevel}
  21208. */
  21209. getLODLevels(): MeshLODLevel[];
  21210. private _sortLODLevels;
  21211. /**
  21212. * Add a mesh as LOD level triggered at the given distance.
  21213. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21214. * @param distance The distance from the center of the object to show this level
  21215. * @param mesh The mesh to be added as LOD level (can be null)
  21216. * @return This mesh (for chaining)
  21217. */
  21218. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21219. /**
  21220. * Returns the LOD level mesh at the passed distance or null if not found.
  21221. * It is related to the method `addLODLevel(distance, mesh)`.
  21222. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21223. * Returns an object Mesh or `null`.
  21224. */
  21225. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21226. /**
  21227. * Remove a mesh from the LOD array
  21228. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21229. * @param {Mesh} mesh The mesh to be removed.
  21230. * @return {Mesh} This mesh (for chaining)
  21231. */
  21232. removeLODLevel(mesh: Mesh): Mesh;
  21233. /**
  21234. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21235. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21236. */
  21237. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21238. /**
  21239. * Returns the mesh internal Geometry object.
  21240. */
  21241. readonly geometry: Nullable<Geometry>;
  21242. /**
  21243. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21244. */
  21245. getTotalVertices(): number;
  21246. /**
  21247. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21248. * 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.
  21249. * You can force the copy with forceCopy === true
  21250. * Returns null if the mesh has no geometry or no vertex buffer.
  21251. * Possible `kind` values :
  21252. * - BABYLON.VertexBuffer.PositionKind
  21253. * - BABYLON.VertexBuffer.UVKind
  21254. * - BABYLON.VertexBuffer.UV2Kind
  21255. * - BABYLON.VertexBuffer.UV3Kind
  21256. * - BABYLON.VertexBuffer.UV4Kind
  21257. * - BABYLON.VertexBuffer.UV5Kind
  21258. * - BABYLON.VertexBuffer.UV6Kind
  21259. * - BABYLON.VertexBuffer.ColorKind
  21260. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21261. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21262. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21263. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21264. */
  21265. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21266. /**
  21267. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21268. * Returns `null` if the mesh has no geometry.
  21269. * Possible `kind` values :
  21270. * - BABYLON.VertexBuffer.PositionKind
  21271. * - BABYLON.VertexBuffer.UVKind
  21272. * - BABYLON.VertexBuffer.UV2Kind
  21273. * - BABYLON.VertexBuffer.UV3Kind
  21274. * - BABYLON.VertexBuffer.UV4Kind
  21275. * - BABYLON.VertexBuffer.UV5Kind
  21276. * - BABYLON.VertexBuffer.UV6Kind
  21277. * - BABYLON.VertexBuffer.ColorKind
  21278. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21279. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21280. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21281. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21282. */
  21283. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21284. isVerticesDataPresent(kind: string): boolean;
  21285. /**
  21286. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21287. * Possible `kind` values :
  21288. * - BABYLON.VertexBuffer.PositionKind
  21289. * - BABYLON.VertexBuffer.UVKind
  21290. * - BABYLON.VertexBuffer.UV2Kind
  21291. * - BABYLON.VertexBuffer.UV3Kind
  21292. * - BABYLON.VertexBuffer.UV4Kind
  21293. * - BABYLON.VertexBuffer.UV5Kind
  21294. * - BABYLON.VertexBuffer.UV6Kind
  21295. * - BABYLON.VertexBuffer.ColorKind
  21296. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21297. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21298. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21299. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21300. */
  21301. isVertexBufferUpdatable(kind: string): boolean;
  21302. /**
  21303. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21304. * Possible `kind` values :
  21305. * - BABYLON.VertexBuffer.PositionKind
  21306. * - BABYLON.VertexBuffer.UVKind
  21307. * - BABYLON.VertexBuffer.UV2Kind
  21308. * - BABYLON.VertexBuffer.UV3Kind
  21309. * - BABYLON.VertexBuffer.UV4Kind
  21310. * - BABYLON.VertexBuffer.UV5Kind
  21311. * - BABYLON.VertexBuffer.UV6Kind
  21312. * - BABYLON.VertexBuffer.ColorKind
  21313. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21314. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21315. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21316. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21317. */
  21318. getVerticesDataKinds(): string[];
  21319. /**
  21320. * Returns a positive integer : the total number of indices in this mesh geometry.
  21321. * Returns zero if the mesh has no geometry.
  21322. */
  21323. getTotalIndices(): number;
  21324. /**
  21325. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21326. * 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.
  21327. * Returns an empty array if the mesh has no geometry.
  21328. */
  21329. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21330. readonly isBlocked: boolean;
  21331. /**
  21332. * Determine if the current mesh is ready to be rendered
  21333. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21334. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21335. * @returns true if all associated assets are ready (material, textures, shaders)
  21336. */
  21337. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21338. /**
  21339. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21340. * This property is pertinent only for updatable parametric shapes.
  21341. */
  21342. readonly areNormalsFrozen: boolean;
  21343. /**
  21344. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21345. * It has no effect at all on other shapes.
  21346. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21347. * Returns the Mesh.
  21348. */
  21349. freezeNormals(): Mesh;
  21350. /**
  21351. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21352. * It has no effect at all on other shapes.
  21353. * It reactivates the mesh normals computation if it was previously frozen.
  21354. * Returns the Mesh.
  21355. */
  21356. unfreezeNormals(): Mesh;
  21357. /**
  21358. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21359. */
  21360. overridenInstanceCount: number;
  21361. _preActivate(): Mesh;
  21362. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21363. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21364. /**
  21365. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21366. * This means the mesh underlying bounding box and sphere are recomputed.
  21367. * Returns the Mesh.
  21368. */
  21369. refreshBoundingInfo(): Mesh;
  21370. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21371. private _getPositionData;
  21372. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21373. subdivide(count: number): void;
  21374. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21375. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21376. /**
  21377. * Sets the mesh VertexBuffer.
  21378. * Returns the Mesh.
  21379. */
  21380. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21381. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21382. /**
  21383. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21384. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21385. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21386. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21387. * Returns the Mesh.
  21388. */
  21389. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21390. /**
  21391. * Creates a un-shared specific occurence of the geometry for the mesh.
  21392. * Returns the Mesh.
  21393. */
  21394. makeGeometryUnique(): Mesh;
  21395. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21396. /**
  21397. * Update the current index buffer
  21398. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21399. * Returns the Mesh.
  21400. */
  21401. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21402. /**
  21403. * Invert the geometry to move from a right handed system to a left handed one.
  21404. * Returns the Mesh.
  21405. */
  21406. toLeftHanded(): Mesh;
  21407. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21408. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21409. /**
  21410. * Registers for this mesh a javascript function called just before the rendering process.
  21411. * This function is passed the current mesh.
  21412. * Return the Mesh.
  21413. */
  21414. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21415. /**
  21416. * Disposes a previously registered javascript function called before the rendering.
  21417. * This function is passed the current mesh.
  21418. * Returns the Mesh.
  21419. */
  21420. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21421. /**
  21422. * Registers for this mesh a javascript function called just after the rendering is complete.
  21423. * This function is passed the current mesh.
  21424. * Returns the Mesh.
  21425. */
  21426. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21427. /**
  21428. * Disposes a previously registered javascript function called after the rendering.
  21429. * This function is passed the current mesh.
  21430. * Return the Mesh.
  21431. */
  21432. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21433. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21434. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21435. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21436. /**
  21437. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  21438. * @param subMesh defines the subMesh to render
  21439. * @param enableAlphaMode defines if alpha mode can be changed
  21440. * @returns the current mesh
  21441. */
  21442. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21443. private _onBeforeDraw;
  21444. /**
  21445. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21446. */
  21447. getEmittedParticleSystems(): IParticleSystem[];
  21448. /**
  21449. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21450. */
  21451. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21452. /**
  21453. * Normalize matrix weights so that all vertices have a total weight set to 1
  21454. */
  21455. cleanMatrixWeights(): void;
  21456. _checkDelayState(): Mesh;
  21457. private _queueLoad;
  21458. /**
  21459. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21460. */
  21461. isInFrustum(frustumPlanes: Plane[]): boolean;
  21462. /**
  21463. * Sets the mesh material by the material or multiMaterial `id` property.
  21464. * The material `id` is a string identifying the material or the multiMaterial.
  21465. * This method returns the Mesh.
  21466. */
  21467. setMaterialByID(id: string): Mesh;
  21468. /**
  21469. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21470. */
  21471. getAnimatables(): IAnimatable[];
  21472. /**
  21473. * Modifies the mesh geometry according to the passed transformation matrix.
  21474. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21475. * The mesh normals are modified accordingly the same transformation.
  21476. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21477. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21478. * Returns the Mesh.
  21479. */
  21480. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21481. /**
  21482. * Modifies the mesh geometry according to its own current World Matrix.
  21483. * The mesh World Matrix is then reset.
  21484. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21485. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21486. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21487. * Returns the Mesh.
  21488. */
  21489. bakeCurrentTransformIntoVertices(): Mesh;
  21490. readonly _positions: Nullable<Vector3[]>;
  21491. _resetPointsArrayCache(): Mesh;
  21492. _generatePointsArray(): boolean;
  21493. /**
  21494. * Returns a new Mesh object generated from the current mesh properties.
  21495. * This method must not get confused with createInstance().
  21496. * The parameter `name` is a string, the name given to the new mesh.
  21497. * The optional parameter `newParent` can be any Node object (default `null`).
  21498. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21499. * 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.
  21500. */
  21501. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21502. /**
  21503. * Releases resources associated with this mesh.
  21504. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21505. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21506. */
  21507. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21508. /**
  21509. * Modifies the mesh geometry according to a displacement map.
  21510. * 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.
  21511. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21512. * This method returns nothing.
  21513. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21514. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21515. * 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.
  21516. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21517. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21518. *
  21519. * Returns the Mesh.
  21520. */
  21521. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21522. /**
  21523. * Modifies the mesh geometry according to a displacementMap buffer.
  21524. * 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.
  21525. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21526. * This method returns nothing.
  21527. * 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.
  21528. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21529. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21530. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21531. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21532. *
  21533. * Returns the Mesh.
  21534. */
  21535. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21536. /**
  21537. * Modify the mesh to get a flat shading rendering.
  21538. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21539. * This method returns the Mesh.
  21540. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21541. */
  21542. convertToFlatShadedMesh(): Mesh;
  21543. /**
  21544. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21545. * In other words, more vertices, no more indices and a single bigger VBO.
  21546. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21547. * Returns the Mesh.
  21548. */
  21549. convertToUnIndexedMesh(): Mesh;
  21550. /**
  21551. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21552. * This method returns the Mesh.
  21553. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21554. */
  21555. flipFaces(flipNormals?: boolean): Mesh;
  21556. /**
  21557. * Creates a new InstancedMesh object from the mesh model.
  21558. * An instance shares the same properties and the same material than its model.
  21559. * Only these properties of each instance can then be set individually :
  21560. * - position
  21561. * - rotation
  21562. * - rotationQuaternion
  21563. * - setPivotMatrix
  21564. * - scaling
  21565. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21566. * Warning : this method is not supported for Line mesh and LineSystem
  21567. */
  21568. createInstance(name: string): InstancedMesh;
  21569. /**
  21570. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21571. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21572. * This method returns the Mesh.
  21573. */
  21574. synchronizeInstances(): Mesh;
  21575. /**
  21576. * Simplify the mesh according to the given array of settings.
  21577. * Function will return immediately and will simplify async. It returns the Mesh.
  21578. * @param settings a collection of simplification settings.
  21579. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21580. * @param type the type of simplification to run.
  21581. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21582. */
  21583. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21584. /**
  21585. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21586. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21587. * This should be used together with the simplification to avoid disappearing triangles.
  21588. * Returns the Mesh.
  21589. * @param successCallback an optional success callback to be called after the optimization finished.
  21590. */
  21591. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21592. serialize(serializationObject: any): void;
  21593. _syncGeometryWithMorphTargetManager(): void;
  21594. /**
  21595. * Returns a new Mesh object parsed from the source provided.
  21596. * The parameter `parsedMesh` is the source.
  21597. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21598. */
  21599. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21600. /**
  21601. * Creates a ribbon mesh.
  21602. * Please consider using the same method from the MeshBuilder class instead.
  21603. * The ribbon is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21604. *
  21605. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21606. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21607. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21608. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21609. * 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.
  21610. * 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.
  21611. * 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
  21612. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21613. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21614. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21615. */
  21616. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21617. /**
  21618. * Creates a plane polygonal mesh. By default, this is a disc.
  21619. * Please consider using the same method from the MeshBuilder class instead.
  21620. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21621. * 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.
  21622. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21623. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21624. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21625. */
  21626. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21627. /**
  21628. * Creates a box mesh.
  21629. * Please consider using the same method from the MeshBuilder class instead.
  21630. * The parameter `size` sets the size (float) of each box side (default 1).
  21631. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21632. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21633. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21634. */
  21635. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21636. /**
  21637. * Creates a sphere mesh.
  21638. * Please consider using the same method from the MeshBuilder class instead.
  21639. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21640. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21641. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21642. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21643. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21644. */
  21645. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21646. /**
  21647. * Creates a cylinder or a cone mesh.
  21648. * Please consider using the same method from the MeshBuilder class instead.
  21649. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21650. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21651. * 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.
  21652. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21653. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21654. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21655. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21656. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21657. */
  21658. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21659. /**
  21660. * Creates a torus mesh.
  21661. * Please consider using the same method from the MeshBuilder class instead.
  21662. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21663. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21664. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21665. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21666. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21667. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21668. */
  21669. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21670. /**
  21671. * Creates a torus knot mesh.
  21672. * Please consider using the same method from the MeshBuilder class instead.
  21673. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21674. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21675. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21676. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21677. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21678. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21679. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21680. */
  21681. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21682. /**
  21683. * Creates a line mesh.
  21684. * Please consider using the same method from the MeshBuilder class instead.
  21685. * 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.
  21686. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21687. * The parameter `points` is an array successive Vector3.
  21688. * 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
  21689. * When updating an instance, remember that only point positions can change, not the number of points.
  21690. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21691. */
  21692. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21693. /**
  21694. * Creates a dashed line mesh.
  21695. * Please consider using the same method from the MeshBuilder class instead.
  21696. * 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.
  21697. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21698. * The parameter `points` is an array successive Vector3.
  21699. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21700. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21701. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21702. * 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
  21703. * When updating an instance, remember that only point positions can change, not the number of points.
  21704. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21705. */
  21706. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21707. /**
  21708. * Creates a polygon mesh.
  21709. * Please consider using the same method from the MeshBuilder class instead.
  21710. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21711. * 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.
  21712. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21713. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21714. * Remember you can only change the shape positions, not their number when updating a polygon.
  21715. */
  21716. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21717. /**
  21718. * Creates an extruded polygon mesh, with depth in the Y direction.
  21719. * Please consider using the same method from the MeshBuilder class instead.
  21720. */
  21721. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21722. /**
  21723. * Creates an extruded shape mesh.
  21724. * The extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21725. * Please consider using the same method from the MeshBuilder class instead.
  21726. *
  21727. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21728. * 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
  21729. * extruded along the Z axis.
  21730. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21731. * 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.
  21732. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21733. * 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
  21734. * 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
  21735. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21736. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21737. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21738. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21739. */
  21740. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21741. /**
  21742. * Creates an custom extruded shape mesh.
  21743. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21744. * Please consider using the same method from the MeshBuilder class instead.
  21745. *
  21746. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21747. * 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
  21748. * extruded along the Z axis.
  21749. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21750. * 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
  21751. * and the distance of this point from the begining of the path :
  21752. * ```javascript
  21753. * var rotationFunction = function(i, distance) {
  21754. * // do things
  21755. * return rotationValue; }
  21756. * ```
  21757. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21758. * 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
  21759. * and the distance of this point from the begining of the path :
  21760. * ```javascript
  21761. * var scaleFunction = function(i, distance) {
  21762. * // do things
  21763. * return scaleValue;}
  21764. * ```
  21765. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21766. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21767. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21768. * 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
  21769. * 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
  21770. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21771. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21772. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21773. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21774. */
  21775. 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;
  21776. /**
  21777. * Creates lathe mesh.
  21778. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21779. * Please consider using the same method from the MeshBuilder class instead.
  21780. * 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
  21781. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21782. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21783. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21784. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21785. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21786. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21787. */
  21788. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21789. /**
  21790. * Creates a plane mesh.
  21791. * Please consider using the same method from the MeshBuilder class instead.
  21792. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21793. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21794. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21795. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21796. */
  21797. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21798. /**
  21799. * Creates a ground mesh.
  21800. * Please consider using the same method from the MeshBuilder class instead.
  21801. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21802. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21803. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21804. */
  21805. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21806. /**
  21807. * Creates a tiled ground mesh.
  21808. * Please consider using the same method from the MeshBuilder class instead.
  21809. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21810. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21811. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21812. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21813. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21814. * numbers of subdivisions on the ground width and height of each tile.
  21815. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21816. */
  21817. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21818. w: number;
  21819. h: number;
  21820. }, precision: {
  21821. w: number;
  21822. h: number;
  21823. }, scene: Scene, updatable?: boolean): Mesh;
  21824. /**
  21825. * Creates a ground mesh from a height map.
  21826. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21827. * Please consider using the same method from the MeshBuilder class instead.
  21828. * The parameter `url` sets the URL of the height map image resource.
  21829. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21830. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21831. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21832. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21833. * 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).
  21834. * This function is passed the newly built mesh :
  21835. * ```javascript
  21836. * function(mesh) { // do things
  21837. * return; }
  21838. * ```
  21839. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21840. */
  21841. 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;
  21842. /**
  21843. * Creates a tube mesh.
  21844. * The tube is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21845. * Please consider using the same method from the MeshBuilder class instead.
  21846. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21847. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21848. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21849. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21850. * 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.
  21851. * It must return a radius value (positive float) :
  21852. * ```javascript
  21853. * var radiusFunction = function(i, distance) {
  21854. * // do things
  21855. * return radius; }
  21856. * ```
  21857. * 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
  21858. * 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
  21859. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21860. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21861. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21862. */
  21863. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21864. (i: number, distance: number): number;
  21865. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21866. /**
  21867. * Creates a polyhedron mesh.
  21868. * Please consider using the same method from the MeshBuilder class instead.
  21869. * 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
  21870. * to choose the wanted type.
  21871. * The parameter `size` (positive float, default 1) sets the polygon size.
  21872. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21873. * 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`.
  21874. * 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
  21875. * 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)`).
  21876. * 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
  21877. * 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.
  21878. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21879. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21880. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21881. */
  21882. static CreatePolyhedron(name: string, options: {
  21883. type?: number;
  21884. size?: number;
  21885. sizeX?: number;
  21886. sizeY?: number;
  21887. sizeZ?: number;
  21888. custom?: any;
  21889. faceUV?: Vector4[];
  21890. faceColors?: Color4[];
  21891. updatable?: boolean;
  21892. sideOrientation?: number;
  21893. }, scene: Scene): Mesh;
  21894. /**
  21895. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21896. * Please consider using the same method from the MeshBuilder class instead.
  21897. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21898. * 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`).
  21899. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21900. * 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.
  21901. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21902. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21903. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21904. */
  21905. static CreateIcoSphere(name: string, options: {
  21906. radius?: number;
  21907. flat?: boolean;
  21908. subdivisions?: number;
  21909. sideOrientation?: number;
  21910. updatable?: boolean;
  21911. }, scene: Scene): Mesh;
  21912. /**
  21913. * Creates a decal mesh.
  21914. * Please consider using the same method from the MeshBuilder class instead.
  21915. * 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.
  21916. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21917. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21918. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21919. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21920. */
  21921. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21922. /**
  21923. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21924. */
  21925. setPositionsForCPUSkinning(): Float32Array;
  21926. /**
  21927. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21928. */
  21929. setNormalsForCPUSkinning(): Float32Array;
  21930. /**
  21931. * Updates the vertex buffer by applying transformation from the bones.
  21932. * Returns the Mesh.
  21933. *
  21934. * @param {skeleton} skeleton to apply
  21935. */
  21936. applySkeleton(skeleton: Skeleton): Mesh;
  21937. /**
  21938. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21939. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21940. */
  21941. static MinMax(meshes: AbstractMesh[]): {
  21942. min: Vector3;
  21943. max: Vector3;
  21944. };
  21945. /**
  21946. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21947. */
  21948. static Center(meshesOrMinMaxVector: {
  21949. min: Vector3;
  21950. max: Vector3;
  21951. } | AbstractMesh[]): Vector3;
  21952. /**
  21953. * Merge the array of meshes into a single mesh for performance reasons.
  21954. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21955. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21956. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21957. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21958. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21959. */
  21960. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21961. }
  21962. }
  21963. declare module BABYLON {
  21964. /**
  21965. * Define an interface for all classes that will get and set the data on vertices
  21966. */
  21967. interface IGetSetVerticesData {
  21968. isVerticesDataPresent(kind: string): boolean;
  21969. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21970. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21971. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21972. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21973. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21974. }
  21975. /**
  21976. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21977. */
  21978. class VertexData {
  21979. /**
  21980. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21981. */
  21982. positions: Nullable<FloatArray>;
  21983. /**
  21984. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21985. */
  21986. normals: Nullable<FloatArray>;
  21987. /**
  21988. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21989. */
  21990. tangents: Nullable<FloatArray>;
  21991. /**
  21992. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21993. */
  21994. uvs: Nullable<FloatArray>;
  21995. /**
  21996. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21997. */
  21998. uvs2: Nullable<FloatArray>;
  21999. /**
  22000. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22001. */
  22002. uvs3: Nullable<FloatArray>;
  22003. /**
  22004. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22005. */
  22006. uvs4: Nullable<FloatArray>;
  22007. /**
  22008. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22009. */
  22010. uvs5: Nullable<FloatArray>;
  22011. /**
  22012. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22013. */
  22014. uvs6: Nullable<FloatArray>;
  22015. /**
  22016. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22017. */
  22018. colors: Nullable<FloatArray>;
  22019. /**
  22020. * 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).
  22021. */
  22022. matricesIndices: Nullable<FloatArray>;
  22023. /**
  22024. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22025. */
  22026. matricesWeights: Nullable<FloatArray>;
  22027. /**
  22028. * An array extending the number of possible indices
  22029. */
  22030. matricesIndicesExtra: Nullable<FloatArray>;
  22031. /**
  22032. * An array extending the number of possible weights when the number of indices is extended
  22033. */
  22034. matricesWeightsExtra: Nullable<FloatArray>;
  22035. /**
  22036. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22037. */
  22038. indices: Nullable<IndicesArray>;
  22039. /**
  22040. * Uses the passed data array to set the set the values for the specified kind of data
  22041. * @param data a linear array of floating numbers
  22042. * @param kind the type of data that is being set, eg positions, colors etc
  22043. */
  22044. set(data: FloatArray, kind: string): void;
  22045. /**
  22046. * Associates the vertexData to the passed Mesh.
  22047. * Sets it as updatable or not (default `false`)
  22048. * @param mesh the mesh the vertexData is applied to
  22049. * @param updatable when used and having the value true allows new data to update the vertexData
  22050. * @returns the VertexData
  22051. */
  22052. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22053. /**
  22054. * Associates the vertexData to the passed Geometry.
  22055. * Sets it as updatable or not (default `false`)
  22056. * @param geometry the geometry the vertexData is applied to
  22057. * @param updatable when used and having the value true allows new data to update the vertexData
  22058. * @returns VertexData
  22059. */
  22060. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22061. /**
  22062. * Updates the associated mesh
  22063. * @param mesh the mesh to be updated
  22064. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22065. * @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
  22066. * @returns VertexData
  22067. */
  22068. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22069. /**
  22070. * Updates the associated geometry
  22071. * @param geometry the geometry to be updated
  22072. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22073. * @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
  22074. * @returns VertexData.
  22075. */
  22076. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22077. private _applyTo;
  22078. private _update;
  22079. /**
  22080. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22081. * @param matrix the transforming matrix
  22082. * @returns the VertexData
  22083. */
  22084. transform(matrix: Matrix): VertexData;
  22085. /**
  22086. * Merges the passed VertexData into the current one
  22087. * @param other the VertexData to be merged into the current one
  22088. * @returns the modified VertexData
  22089. */
  22090. merge(other: VertexData): VertexData;
  22091. private _mergeElement;
  22092. private _validate;
  22093. /**
  22094. * Serializes the VertexData
  22095. * @returns a serialized object
  22096. */
  22097. serialize(): any;
  22098. /**
  22099. * Extracts the vertexData from a mesh
  22100. * @param mesh the mesh from which to extract the VertexData
  22101. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22102. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22103. * @returns the object VertexData associated to the passed mesh
  22104. */
  22105. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22106. /**
  22107. * Extracts the vertexData from the geometry
  22108. * @param geometry the geometry from which to extract the VertexData
  22109. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22110. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22111. * @returns the object VertexData associated to the passed mesh
  22112. */
  22113. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22114. private static _ExtractFrom;
  22115. /**
  22116. * Creates the VertexData for a Ribbon
  22117. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22118. * * pathArray array of paths, each of which an array of successive Vector3
  22119. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22120. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22121. * * 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
  22122. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22123. * * 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)
  22124. * * 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)
  22125. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22126. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22127. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22128. * @returns the VertexData of the ribbon
  22129. */
  22130. static CreateRibbon(options: {
  22131. pathArray: Vector3[][];
  22132. closeArray?: boolean;
  22133. closePath?: boolean;
  22134. offset?: number;
  22135. sideOrientation?: number;
  22136. frontUVs?: Vector4;
  22137. backUVs?: Vector4;
  22138. invertUV?: boolean;
  22139. uvs?: Vector2[];
  22140. colors?: Color4[];
  22141. }): VertexData;
  22142. /**
  22143. * Creates the VertexData for a box
  22144. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22145. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22146. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22147. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22148. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22149. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22150. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22151. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22152. * * 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)
  22153. * * 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)
  22154. * @returns the VertexData of the box
  22155. */
  22156. static CreateBox(options: {
  22157. size?: number;
  22158. width?: number;
  22159. height?: number;
  22160. depth?: number;
  22161. faceUV?: Vector4[];
  22162. faceColors?: Color4[];
  22163. sideOrientation?: number;
  22164. frontUVs?: Vector4;
  22165. backUVs?: Vector4;
  22166. }): VertexData;
  22167. /**
  22168. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22169. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22170. * * segments sets the number of horizontal strips optional, default 32
  22171. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22172. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22173. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22174. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22175. * * 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
  22176. * * 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
  22177. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22178. * * 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)
  22179. * * 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)
  22180. * @returns the VertexData of the ellipsoid
  22181. */
  22182. static CreateSphere(options: {
  22183. segments?: number;
  22184. diameter?: number;
  22185. diameterX?: number;
  22186. diameterY?: number;
  22187. diameterZ?: number;
  22188. arc?: number;
  22189. slice?: number;
  22190. sideOrientation?: number;
  22191. frontUVs?: Vector4;
  22192. backUVs?: Vector4;
  22193. }): VertexData;
  22194. /**
  22195. * Creates the VertexData for a cylinder, cone or prism
  22196. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22197. * * height sets the height (y direction) of the cylinder, optional, default 2
  22198. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22199. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22200. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22201. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22202. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22203. * * 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
  22204. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22205. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22206. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22207. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22208. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22209. * * 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)
  22210. * * 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)
  22211. * @returns the VertexData of the cylinder, cone or prism
  22212. */
  22213. static CreateCylinder(options: {
  22214. height?: number;
  22215. diameterTop?: number;
  22216. diameterBottom?: number;
  22217. diameter?: number;
  22218. tessellation?: number;
  22219. subdivisions?: number;
  22220. arc?: number;
  22221. faceColors?: Color4[];
  22222. faceUV?: Vector4[];
  22223. hasRings?: boolean;
  22224. enclose?: boolean;
  22225. sideOrientation?: number;
  22226. frontUVs?: Vector4;
  22227. backUVs?: Vector4;
  22228. }): VertexData;
  22229. /**
  22230. * Creates the VertexData for a torus
  22231. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22232. * * diameter the diameter of the torus, optional default 1
  22233. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22234. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22235. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22236. * * 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)
  22237. * * 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)
  22238. * @returns the VertexData of the torus
  22239. */
  22240. static CreateTorus(options: {
  22241. diameter?: number;
  22242. thickness?: number;
  22243. tessellation?: number;
  22244. sideOrientation?: number;
  22245. frontUVs?: Vector4;
  22246. backUVs?: Vector4;
  22247. }): VertexData;
  22248. /**
  22249. * Creates the VertexData of the LineSystem
  22250. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22251. * - lines an array of lines, each line being an array of successive Vector3
  22252. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22253. * @returns the VertexData of the LineSystem
  22254. */
  22255. static CreateLineSystem(options: {
  22256. lines: Vector3[][];
  22257. colors?: Nullable<Color4[][]>;
  22258. }): VertexData;
  22259. /**
  22260. * Create the VertexData for a DashedLines
  22261. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22262. * - points an array successive Vector3
  22263. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22264. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22265. * - dashNb the intended total number of dashes, optional, default 200
  22266. * @returns the VertexData for the DashedLines
  22267. */
  22268. static CreateDashedLines(options: {
  22269. points: Vector3[];
  22270. dashSize?: number;
  22271. gapSize?: number;
  22272. dashNb?: number;
  22273. }): VertexData;
  22274. /**
  22275. * Creates the VertexData for a Ground
  22276. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22277. * - width the width (x direction) of the ground, optional, default 1
  22278. * - height the height (z direction) of the ground, optional, default 1
  22279. * - subdivisions the number of subdivisions per side, optional, default 1
  22280. * @returns the VertexData of the Ground
  22281. */
  22282. static CreateGround(options: {
  22283. width?: number;
  22284. height?: number;
  22285. subdivisions?: number;
  22286. subdivisionsX?: number;
  22287. subdivisionsY?: number;
  22288. }): VertexData;
  22289. /**
  22290. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22291. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22292. * * xmin the ground minimum X coordinate, optional, default -1
  22293. * * zmin the ground minimum Z coordinate, optional, default -1
  22294. * * xmax the ground maximum X coordinate, optional, default 1
  22295. * * zmax the ground maximum Z coordinate, optional, default 1
  22296. * * 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}
  22297. * * 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}
  22298. * @returns the VertexData of the TiledGround
  22299. */
  22300. static CreateTiledGround(options: {
  22301. xmin: number;
  22302. zmin: number;
  22303. xmax: number;
  22304. zmax: number;
  22305. subdivisions?: {
  22306. w: number;
  22307. h: number;
  22308. };
  22309. precision?: {
  22310. w: number;
  22311. h: number;
  22312. };
  22313. }): VertexData;
  22314. /**
  22315. * Creates the VertexData of the Ground designed from a heightmap
  22316. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22317. * * width the width (x direction) of the ground
  22318. * * height the height (z direction) of the ground
  22319. * * subdivisions the number of subdivisions per side
  22320. * * minHeight the minimum altitude on the ground, optional, default 0
  22321. * * maxHeight the maximum altitude on the ground, optional default 1
  22322. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22323. * * buffer the array holding the image color data
  22324. * * bufferWidth the width of image
  22325. * * bufferHeight the height of image
  22326. * @returns the VertexData of the Ground designed from a heightmap
  22327. */
  22328. static CreateGroundFromHeightMap(options: {
  22329. width: number;
  22330. height: number;
  22331. subdivisions: number;
  22332. minHeight: number;
  22333. maxHeight: number;
  22334. colorFilter: Color3;
  22335. buffer: Uint8Array;
  22336. bufferWidth: number;
  22337. bufferHeight: number;
  22338. }): VertexData;
  22339. /**
  22340. * Creates the VertexData for a Plane
  22341. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22342. * * size sets the width and height of the plane to the value of size, optional default 1
  22343. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22344. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22345. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22346. * * 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)
  22347. * * 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)
  22348. * @returns the VertexData of the box
  22349. */
  22350. static CreatePlane(options: {
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. sideOrientation?: number;
  22355. frontUVs?: Vector4;
  22356. backUVs?: Vector4;
  22357. }): VertexData;
  22358. /**
  22359. * Creates the VertexData of the Disc or regular Polygon
  22360. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22361. * * radius the radius of the disc, optional default 0.5
  22362. * * tessellation the number of polygon sides, optional, default 64
  22363. * * 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
  22364. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22365. * * 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)
  22366. * * 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)
  22367. * @returns the VertexData of the box
  22368. */
  22369. static CreateDisc(options: {
  22370. radius?: number;
  22371. tessellation?: number;
  22372. arc?: number;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22379. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22380. * @param polygon a mesh built from polygonTriangulation.build()
  22381. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22382. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22383. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22384. * @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)
  22385. * @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)
  22386. * @returns the VertexData of the Polygon
  22387. */
  22388. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22389. /**
  22390. * Creates the VertexData of the IcoSphere
  22391. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22392. * * radius the radius of the IcoSphere, optional default 1
  22393. * * radiusX allows stretching in the x direction, optional, default radius
  22394. * * radiusY allows stretching in the y direction, optional, default radius
  22395. * * radiusZ allows stretching in the z direction, optional, default radius
  22396. * * flat when true creates a flat shaded mesh, optional, default true
  22397. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22398. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22399. * * 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)
  22400. * * 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)
  22401. * @returns the VertexData of the IcoSphere
  22402. */
  22403. static CreateIcoSphere(options: {
  22404. radius?: number;
  22405. radiusX?: number;
  22406. radiusY?: number;
  22407. radiusZ?: number;
  22408. flat?: boolean;
  22409. subdivisions?: number;
  22410. sideOrientation?: number;
  22411. frontUVs?: Vector4;
  22412. backUVs?: Vector4;
  22413. }): VertexData;
  22414. /**
  22415. * Creates the VertexData for a Polyhedron
  22416. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22417. * * type provided types are:
  22418. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22419. * * 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)
  22420. * * size the size of the IcoSphere, optional default 1
  22421. * * sizeX allows stretching in the x direction, optional, default size
  22422. * * sizeY allows stretching in the y direction, optional, default size
  22423. * * sizeZ allows stretching in the z direction, optional, default size
  22424. * * 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
  22425. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22426. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22427. * * flat when true creates a flat shaded mesh, optional, default true
  22428. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22429. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22430. * * 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)
  22431. * * 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)
  22432. * @returns the VertexData of the Polyhedron
  22433. */
  22434. static CreatePolyhedron(options: {
  22435. type?: number;
  22436. size?: number;
  22437. sizeX?: number;
  22438. sizeY?: number;
  22439. sizeZ?: number;
  22440. custom?: any;
  22441. faceUV?: Vector4[];
  22442. faceColors?: Color4[];
  22443. flat?: boolean;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for a TorusKnot
  22450. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22451. * * radius the radius of the torus knot, optional, default 2
  22452. * * tube the thickness of the tube, optional, default 0.5
  22453. * * radialSegments the number of sides on each tube segments, optional, default 32
  22454. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22455. * * p the number of windings around the z axis, optional, default 2
  22456. * * q the number of windings around the x axis, optional, default 3
  22457. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22458. * * 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)
  22459. * * 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)
  22460. * @returns the VertexData of the Torus Knot
  22461. */
  22462. static CreateTorusKnot(options: {
  22463. radius?: number;
  22464. tube?: number;
  22465. radialSegments?: number;
  22466. tubularSegments?: number;
  22467. p?: number;
  22468. q?: number;
  22469. sideOrientation?: number;
  22470. frontUVs?: Vector4;
  22471. backUVs?: Vector4;
  22472. }): VertexData;
  22473. /**
  22474. * Compute normals for given positions and indices
  22475. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22476. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22477. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22478. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22479. * * facetNormals : optional array of facet normals (vector3)
  22480. * * facetPositions : optional array of facet positions (vector3)
  22481. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22482. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22483. * * bInfo : optional bounding info, required for facetPartitioning computation
  22484. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22485. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22486. * * useRightHandedSystem: optional boolean to for right handed system computation
  22487. * * depthSort : optional boolean to enable the facet depth sort computation
  22488. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22489. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22490. */
  22491. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22492. facetNormals?: any;
  22493. facetPositions?: any;
  22494. facetPartitioning?: any;
  22495. ratio?: number;
  22496. bInfo?: any;
  22497. bbSize?: Vector3;
  22498. subDiv?: any;
  22499. useRightHandedSystem?: boolean;
  22500. depthSort?: boolean;
  22501. distanceTo?: Vector3;
  22502. depthSortedFacets?: any;
  22503. }): void;
  22504. private static _ComputeSides;
  22505. /**
  22506. * Applies VertexData created from the imported parameters to the geometry
  22507. * @param parsedVertexData the parsed data from an imported file
  22508. * @param geometry the geometry to apply the VertexData to
  22509. */
  22510. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22511. }
  22512. }
  22513. declare module BABYLON {
  22514. /**
  22515. * Class containing static functions to help procedurally build meshes
  22516. */
  22517. class MeshBuilder {
  22518. private static updateSideOrientation;
  22519. /**
  22520. * Creates a box mesh
  22521. * * The parameter `size` sets the size (float) of each box side (default 1)
  22522. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22523. * * 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)
  22524. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22526. * * 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
  22527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22528. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22529. * @param name defines the name of the mesh
  22530. * @param options defines the options used to create the mesh
  22531. * @param scene defines the hosting scene
  22532. * @returns the box mesh
  22533. */
  22534. static CreateBox(name: string, options: {
  22535. size?: number;
  22536. width?: number;
  22537. height?: number;
  22538. depth?: number;
  22539. faceUV?: Vector4[];
  22540. faceColors?: Color4[];
  22541. sideOrientation?: number;
  22542. frontUVs?: Vector4;
  22543. backUVs?: Vector4;
  22544. updatable?: boolean;
  22545. }, scene?: Nullable<Scene>): Mesh;
  22546. /**
  22547. * Creates a sphere mesh
  22548. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22549. * * 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`)
  22550. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22551. * * 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
  22552. * * 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)
  22553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22554. * * 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
  22555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22556. * @param name defines the name of the mesh
  22557. * @param options defines the options used to create the mesh
  22558. * @param scene defines the hosting scene
  22559. * @returns the sphere mesh
  22560. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22561. */
  22562. static CreateSphere(name: string, options: {
  22563. segments?: number;
  22564. diameter?: number;
  22565. diameterX?: number;
  22566. diameterY?: number;
  22567. diameterZ?: number;
  22568. arc?: number;
  22569. slice?: number;
  22570. sideOrientation?: number;
  22571. frontUVs?: Vector4;
  22572. backUVs?: Vector4;
  22573. updatable?: boolean;
  22574. }, scene: any): Mesh;
  22575. /**
  22576. * Creates a plane polygonal mesh. By default, this is a disc
  22577. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22578. * * 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
  22579. * * 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
  22580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22581. * * 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
  22582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22583. * @param name defines the name of the mesh
  22584. * @param options defines the options used to create the mesh
  22585. * @param scene defines the hosting scene
  22586. * @returns the plane polygonal mesh
  22587. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22588. */
  22589. static CreateDisc(name: string, options: {
  22590. radius?: number;
  22591. tessellation?: number;
  22592. arc?: number;
  22593. updatable?: boolean;
  22594. sideOrientation?: number;
  22595. frontUVs?: Vector4;
  22596. backUVs?: Vector4;
  22597. }, scene?: Nullable<Scene>): Mesh;
  22598. /**
  22599. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22600. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22601. * * 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`)
  22602. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22603. * * 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
  22604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22605. * * 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
  22606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22607. * @param name defines the name of the mesh
  22608. * @param options defines the options used to create the mesh
  22609. * @param scene defines the hosting scene
  22610. * @returns the icosahedron mesh
  22611. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22612. */
  22613. static CreateIcoSphere(name: string, options: {
  22614. radius?: number;
  22615. radiusX?: number;
  22616. radiusY?: number;
  22617. radiusZ?: number;
  22618. flat?: boolean;
  22619. subdivisions?: number;
  22620. sideOrientation?: number;
  22621. frontUVs?: Vector4;
  22622. backUVs?: Vector4;
  22623. updatable?: boolean;
  22624. }, scene: Scene): Mesh;
  22625. /**
  22626. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22627. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22628. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22629. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22630. * * 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
  22631. * * 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
  22632. * * 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
  22633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22634. * * 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
  22635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22636. * * 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
  22637. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22638. * * 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
  22639. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22641. * @param name defines the name of the mesh
  22642. * @param options defines the options used to create the mesh
  22643. * @param scene defines the hosting scene
  22644. * @returns the ribbon mesh
  22645. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22646. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22647. */
  22648. static CreateRibbon(name: string, options: {
  22649. pathArray: Vector3[][];
  22650. closeArray?: boolean;
  22651. closePath?: boolean;
  22652. offset?: number;
  22653. updatable?: boolean;
  22654. sideOrientation?: number;
  22655. frontUVs?: Vector4;
  22656. backUVs?: Vector4;
  22657. instance?: Mesh;
  22658. invertUV?: boolean;
  22659. uvs?: Vector2[];
  22660. colors?: Color4[];
  22661. }, scene?: Nullable<Scene>): Mesh;
  22662. /**
  22663. * Creates a cylinder or a cone mesh
  22664. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22665. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22666. * * 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.
  22667. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22668. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22669. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22670. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22671. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22672. * * 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).
  22673. * * 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
  22674. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22675. * * 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
  22676. * * 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.
  22677. * * If `enclose` is false, a ring surface is one element.
  22678. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22679. * * 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
  22680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22681. * * 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
  22682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22683. * @param name defines the name of the mesh
  22684. * @param options defines the options used to create the mesh
  22685. * @param scene defines the hosting scene
  22686. * @returns the cylinder mesh
  22687. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22688. */
  22689. static CreateCylinder(name: string, options: {
  22690. height?: number;
  22691. diameterTop?: number;
  22692. diameterBottom?: number;
  22693. diameter?: number;
  22694. tessellation?: number;
  22695. subdivisions?: number;
  22696. arc?: number;
  22697. faceColors?: Color4[];
  22698. faceUV?: Vector4[];
  22699. updatable?: boolean;
  22700. hasRings?: boolean;
  22701. enclose?: boolean;
  22702. sideOrientation?: number;
  22703. frontUVs?: Vector4;
  22704. backUVs?: Vector4;
  22705. }, scene: any): Mesh;
  22706. /**
  22707. * Creates a torus mesh
  22708. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22709. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22710. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22712. * * 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
  22713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22714. * @param name defines the name of the mesh
  22715. * @param options defines the options used to create the mesh
  22716. * @param scene defines the hosting scene
  22717. * @returns the torus mesh
  22718. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22719. */
  22720. static CreateTorus(name: string, options: {
  22721. diameter?: number;
  22722. thickness?: number;
  22723. tessellation?: number;
  22724. updatable?: boolean;
  22725. sideOrientation?: number;
  22726. frontUVs?: Vector4;
  22727. backUVs?: Vector4;
  22728. }, scene: any): Mesh;
  22729. /**
  22730. * Creates a torus knot mesh
  22731. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22732. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22733. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22734. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22736. * * 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
  22737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22738. * @param name defines the name of the mesh
  22739. * @param options defines the options used to create the mesh
  22740. * @param scene defines the hosting scene
  22741. * @returns the torus knot mesh
  22742. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22743. */
  22744. static CreateTorusKnot(name: string, options: {
  22745. radius?: number;
  22746. tube?: number;
  22747. radialSegments?: number;
  22748. tubularSegments?: number;
  22749. p?: number;
  22750. q?: number;
  22751. updatable?: boolean;
  22752. sideOrientation?: number;
  22753. frontUVs?: Vector4;
  22754. backUVs?: Vector4;
  22755. }, scene: any): Mesh;
  22756. /**
  22757. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22758. * * 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
  22759. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22760. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22761. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22762. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22763. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22764. * * 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
  22765. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22767. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22768. * @param name defines the name of the new line system
  22769. * @param options defines the options used to create the line system
  22770. * @param scene defines the hosting scene
  22771. * @returns a new line system mesh
  22772. */
  22773. static CreateLineSystem(name: string, options: {
  22774. lines: Vector3[][];
  22775. updatable?: boolean;
  22776. instance?: Nullable<LinesMesh>;
  22777. colors?: Nullable<Color4[][]>;
  22778. useVertexAlpha?: boolean;
  22779. }, scene: Nullable<Scene>): LinesMesh;
  22780. /**
  22781. * Creates a line mesh
  22782. * 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
  22783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22784. * * The parameter `points` is an array successive Vector3
  22785. * * 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
  22786. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22788. * * When updating an instance, remember that only point positions can change, not the number of points
  22789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22790. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22791. * @param name defines the name of the new line system
  22792. * @param options defines the options used to create the line system
  22793. * @param scene defines the hosting scene
  22794. * @returns a new line mesh
  22795. */
  22796. static CreateLines(name: string, options: {
  22797. points: Vector3[];
  22798. updatable?: boolean;
  22799. instance?: Nullable<LinesMesh>;
  22800. colors?: Color4[];
  22801. useVertexAlpha?: boolean;
  22802. }, scene?: Nullable<Scene>): LinesMesh;
  22803. /**
  22804. * Creates a dashed line mesh
  22805. * * 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
  22806. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22807. * * The parameter `points` is an array successive Vector3
  22808. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22809. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22810. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22811. * * 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
  22812. * * When updating an instance, remember that only point positions can change, not the number of points
  22813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22814. * @param name defines the name of the mesh
  22815. * @param options defines the options used to create the mesh
  22816. * @param scene defines the hosting scene
  22817. * @returns the dashed line mesh
  22818. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22819. */
  22820. static CreateDashedLines(name: string, options: {
  22821. points: Vector3[];
  22822. dashSize?: number;
  22823. gapSize?: number;
  22824. dashNb?: number;
  22825. updatable?: boolean;
  22826. instance?: LinesMesh;
  22827. }, scene?: Nullable<Scene>): LinesMesh;
  22828. /**
  22829. * 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.
  22830. * * 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.
  22831. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22832. * * 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.
  22833. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22834. * * 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
  22835. * * 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
  22836. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22838. * * 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
  22839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22841. * @param name defines the name of the mesh
  22842. * @param options defines the options used to create the mesh
  22843. * @param scene defines the hosting scene
  22844. * @returns the extruded shape mesh
  22845. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22846. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22847. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22848. */
  22849. static ExtrudeShape(name: string, options: {
  22850. shape: Vector3[];
  22851. path: Vector3[];
  22852. scale?: number;
  22853. rotation?: number;
  22854. cap?: number;
  22855. updatable?: boolean;
  22856. sideOrientation?: number;
  22857. frontUVs?: Vector4;
  22858. backUVs?: Vector4;
  22859. instance?: Mesh;
  22860. invertUV?: boolean;
  22861. }, scene?: Nullable<Scene>): Mesh;
  22862. /**
  22863. * Creates an custom extruded shape mesh.
  22864. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22865. * * 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.
  22866. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22867. * * 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
  22868. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22869. * * 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
  22870. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22871. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22872. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22873. * * 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
  22874. * * 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
  22875. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22877. * * 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
  22878. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22880. * @param name defines the name of the mesh
  22881. * @param options defines the options used to create the mesh
  22882. * @param scene defines the hosting scene
  22883. * @returns the custom extruded shape mesh
  22884. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22885. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22886. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22887. */
  22888. static ExtrudeShapeCustom(name: string, options: {
  22889. shape: Vector3[];
  22890. path: Vector3[];
  22891. scaleFunction?: any;
  22892. rotationFunction?: any;
  22893. ribbonCloseArray?: boolean;
  22894. ribbonClosePath?: boolean;
  22895. cap?: number;
  22896. updatable?: boolean;
  22897. sideOrientation?: number;
  22898. frontUVs?: Vector4;
  22899. backUVs?: Vector4;
  22900. instance?: Mesh;
  22901. invertUV?: boolean;
  22902. }, scene: Scene): Mesh;
  22903. /**
  22904. * Creates lathe mesh.
  22905. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22906. * * 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
  22907. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22908. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22909. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  22910. * * 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
  22911. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22912. * * 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
  22913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22914. * * 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
  22915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22917. * @param name defines the name of the mesh
  22918. * @param options defines the options used to create the mesh
  22919. * @param scene defines the hosting scene
  22920. * @returns the lathe mesh
  22921. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22922. */
  22923. static CreateLathe(name: string, options: {
  22924. shape: Vector3[];
  22925. radius?: number;
  22926. tessellation?: number;
  22927. clip?: number;
  22928. arc?: number;
  22929. closed?: boolean;
  22930. updatable?: boolean;
  22931. sideOrientation?: number;
  22932. frontUVs?: Vector4;
  22933. backUVs?: Vector4;
  22934. cap?: number;
  22935. invertUV?: boolean;
  22936. }, scene: Scene): Mesh;
  22937. /**
  22938. * Creates a plane mesh
  22939. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22940. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22941. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22943. * * 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
  22944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22945. * @param name defines the name of the mesh
  22946. * @param options defines the options used to create the mesh
  22947. * @param scene defines the hosting scene
  22948. * @returns the plane mesh
  22949. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22950. */
  22951. static CreatePlane(name: string, options: {
  22952. size?: number;
  22953. width?: number;
  22954. height?: number;
  22955. sideOrientation?: number;
  22956. frontUVs?: Vector4;
  22957. backUVs?: Vector4;
  22958. updatable?: boolean;
  22959. sourcePlane?: Plane;
  22960. }, scene: Scene): Mesh;
  22961. /**
  22962. * Creates a ground mesh
  22963. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22964. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22966. * @param name defines the name of the mesh
  22967. * @param options defines the options used to create the mesh
  22968. * @param scene defines the hosting scene
  22969. * @returns the ground mesh
  22970. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22971. */
  22972. static CreateGround(name: string, options: {
  22973. width?: number;
  22974. height?: number;
  22975. subdivisions?: number;
  22976. subdivisionsX?: number;
  22977. subdivisionsY?: number;
  22978. updatable?: boolean;
  22979. }, scene: any): Mesh;
  22980. /**
  22981. * Creates a tiled ground mesh
  22982. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22983. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22984. * * 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
  22985. * * 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
  22986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22987. * @param name defines the name of the mesh
  22988. * @param options defines the options used to create the mesh
  22989. * @param scene defines the hosting scene
  22990. * @returns the tiled ground mesh
  22991. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22992. */
  22993. static CreateTiledGround(name: string, options: {
  22994. xmin: number;
  22995. zmin: number;
  22996. xmax: number;
  22997. zmax: number;
  22998. subdivisions?: {
  22999. w: number;
  23000. h: number;
  23001. };
  23002. precision?: {
  23003. w: number;
  23004. h: number;
  23005. };
  23006. updatable?: boolean;
  23007. }, scene: Scene): Mesh;
  23008. /**
  23009. * Creates a ground mesh from a height map
  23010. * * The parameter `url` sets the URL of the height map image resource.
  23011. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23012. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23013. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23014. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23015. * * 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.
  23016. * * 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).
  23017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23018. * @param name defines the name of the mesh
  23019. * @param url defines the url to the height map
  23020. * @param options defines the options used to create the mesh
  23021. * @param scene defines the hosting scene
  23022. * @returns the ground mesh
  23023. * @see http://doc.babylonjs.com/babylon101/height_map
  23024. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23025. */
  23026. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23027. width?: number;
  23028. height?: number;
  23029. subdivisions?: number;
  23030. minHeight?: number;
  23031. maxHeight?: number;
  23032. colorFilter?: Color3;
  23033. updatable?: boolean;
  23034. onReady?: (mesh: GroundMesh) => void;
  23035. }, scene: Scene): GroundMesh;
  23036. /**
  23037. * Creates a polygon mesh
  23038. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23039. * * 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
  23040. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23042. * * 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)
  23043. * * Remember you can only change the shape positions, not their number when updating a polygon
  23044. * @param name defines the name of the mesh
  23045. * @param options defines the options used to create the mesh
  23046. * @param scene defines the hosting scene
  23047. * @returns the polygon mesh
  23048. */
  23049. static CreatePolygon(name: string, options: {
  23050. shape: Vector3[];
  23051. holes?: Vector3[][];
  23052. depth?: number;
  23053. faceUV?: Vector4[];
  23054. faceColors?: Color4[];
  23055. updatable?: boolean;
  23056. sideOrientation?: number;
  23057. frontUVs?: Vector4;
  23058. backUVs?: Vector4;
  23059. }, scene: Scene): Mesh;
  23060. /**
  23061. * Creates an extruded polygon mesh, with depth in the Y direction.
  23062. * * 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)
  23063. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23064. * @param name defines the name of the mesh
  23065. * @param options defines the options used to create the mesh
  23066. * @param scene defines the hosting scene
  23067. * @returns the polygon mesh
  23068. */
  23069. static ExtrudePolygon(name: string, options: {
  23070. shape: Vector3[];
  23071. holes?: Vector3[][];
  23072. depth?: number;
  23073. faceUV?: Vector4[];
  23074. faceColors?: Color4[];
  23075. updatable?: boolean;
  23076. sideOrientation?: number;
  23077. frontUVs?: Vector4;
  23078. backUVs?: Vector4;
  23079. }, scene: Scene): Mesh;
  23080. /**
  23081. * Creates a tube mesh.
  23082. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23083. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23084. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23085. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23086. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23087. * * 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)
  23088. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23089. * * 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
  23090. * * 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
  23091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23092. * * 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
  23093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23095. * @param name defines the name of the mesh
  23096. * @param options defines the options used to create the mesh
  23097. * @param scene defines the hosting scene
  23098. * @returns the tube mesh
  23099. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23100. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23101. */
  23102. static CreateTube(name: string, options: {
  23103. path: Vector3[];
  23104. radius?: number;
  23105. tessellation?: number;
  23106. radiusFunction?: {
  23107. (i: number, distance: number): number;
  23108. };
  23109. cap?: number;
  23110. arc?: number;
  23111. updatable?: boolean;
  23112. sideOrientation?: number;
  23113. frontUVs?: Vector4;
  23114. backUVs?: Vector4;
  23115. instance?: Mesh;
  23116. invertUV?: boolean;
  23117. }, scene: Scene): Mesh;
  23118. /**
  23119. * Creates a polyhedron mesh
  23120. * * 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
  23121. * * The parameter `size` (positive float, default 1) sets the polygon size
  23122. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23123. * * 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`
  23124. * * 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
  23125. * * 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)`)
  23126. * * 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
  23127. * * 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
  23128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23129. * * 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
  23130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23131. * @param name defines the name of the mesh
  23132. * @param options defines the options used to create the mesh
  23133. * @param scene defines the hosting scene
  23134. * @returns the polyhedron mesh
  23135. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23136. */
  23137. static CreatePolyhedron(name: string, options: {
  23138. type?: number;
  23139. size?: number;
  23140. sizeX?: number;
  23141. sizeY?: number;
  23142. sizeZ?: number;
  23143. custom?: any;
  23144. faceUV?: Vector4[];
  23145. faceColors?: Color4[];
  23146. flat?: boolean;
  23147. updatable?: boolean;
  23148. sideOrientation?: number;
  23149. frontUVs?: Vector4;
  23150. backUVs?: Vector4;
  23151. }, scene: Scene): Mesh;
  23152. /**
  23153. * Creates a decal mesh.
  23154. * 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
  23155. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23156. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23157. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23158. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23159. * @param name defines the name of the mesh
  23160. * @param sourceMesh defines the mesh where the decal must be applied
  23161. * @param options defines the options used to create the mesh
  23162. * @param scene defines the hosting scene
  23163. * @returns the decal mesh
  23164. * @see http://doc.babylonjs.com/how_to/decals
  23165. */
  23166. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23167. position?: Vector3;
  23168. normal?: Vector3;
  23169. size?: Vector3;
  23170. angle?: number;
  23171. }): Mesh;
  23172. private static _ExtrudeShapeGeneric;
  23173. }
  23174. }
  23175. declare module BABYLON {
  23176. class MeshLODLevel {
  23177. distance: number;
  23178. mesh: Nullable<Mesh>;
  23179. constructor(distance: number, mesh: Nullable<Mesh>);
  23180. }
  23181. }
  23182. declare module BABYLON {
  23183. /**
  23184. * A simplifier interface for future simplification implementations.
  23185. */
  23186. interface ISimplifier {
  23187. /**
  23188. * Simplification of a given mesh according to the given settings.
  23189. * Since this requires computation, it is assumed that the function runs async.
  23190. * @param settings The settings of the simplification, including quality and distance
  23191. * @param successCallback A callback that will be called after the mesh was simplified.
  23192. * @param errorCallback in case of an error, this callback will be called. optional.
  23193. */
  23194. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23195. }
  23196. /**
  23197. * Expected simplification settings.
  23198. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23199. */
  23200. interface ISimplificationSettings {
  23201. quality: number;
  23202. distance: number;
  23203. optimizeMesh?: boolean;
  23204. }
  23205. class SimplificationSettings implements ISimplificationSettings {
  23206. quality: number;
  23207. distance: number;
  23208. optimizeMesh?: boolean | undefined;
  23209. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23210. }
  23211. interface ISimplificationTask {
  23212. settings: Array<ISimplificationSettings>;
  23213. simplificationType: SimplificationType;
  23214. mesh: Mesh;
  23215. successCallback?: () => void;
  23216. parallelProcessing: boolean;
  23217. }
  23218. class SimplificationQueue {
  23219. private _simplificationArray;
  23220. running: boolean;
  23221. constructor();
  23222. addTask(task: ISimplificationTask): void;
  23223. executeNext(): void;
  23224. runSimplification(task: ISimplificationTask): void;
  23225. private getSimplifier;
  23226. }
  23227. /**
  23228. * The implemented types of simplification
  23229. * At the moment only Quadratic Error Decimation is implemented
  23230. */
  23231. enum SimplificationType {
  23232. /** Quadratic error decimation */
  23233. QUADRATIC = 0
  23234. }
  23235. class DecimationTriangle {
  23236. vertices: Array<DecimationVertex>;
  23237. normal: Vector3;
  23238. error: Array<number>;
  23239. deleted: boolean;
  23240. isDirty: boolean;
  23241. borderFactor: number;
  23242. deletePending: boolean;
  23243. originalOffset: number;
  23244. constructor(vertices: Array<DecimationVertex>);
  23245. }
  23246. class DecimationVertex {
  23247. position: Vector3;
  23248. id: number;
  23249. q: QuadraticMatrix;
  23250. isBorder: boolean;
  23251. triangleStart: number;
  23252. triangleCount: number;
  23253. originalOffsets: Array<number>;
  23254. constructor(position: Vector3, id: number);
  23255. updatePosition(newPosition: Vector3): void;
  23256. }
  23257. class QuadraticMatrix {
  23258. data: Array<number>;
  23259. constructor(data?: Array<number>);
  23260. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23261. addInPlace(matrix: QuadraticMatrix): void;
  23262. addArrayInPlace(data: Array<number>): void;
  23263. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23264. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23265. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23266. }
  23267. class Reference {
  23268. vertexId: number;
  23269. triangleId: number;
  23270. constructor(vertexId: number, triangleId: number);
  23271. }
  23272. /**
  23273. * An implementation of the Quadratic Error simplification algorithm.
  23274. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23275. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23276. * @author RaananW
  23277. */
  23278. class QuadraticErrorSimplification implements ISimplifier {
  23279. private _mesh;
  23280. private triangles;
  23281. private vertices;
  23282. private references;
  23283. private _reconstructedMesh;
  23284. syncIterations: number;
  23285. aggressiveness: number;
  23286. decimationIterations: number;
  23287. boundingBoxEpsilon: number;
  23288. constructor(_mesh: Mesh);
  23289. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23290. private runDecimation;
  23291. private initWithMesh;
  23292. private init;
  23293. private reconstructMesh;
  23294. private initDecimatedMesh;
  23295. private isFlipped;
  23296. private updateTriangles;
  23297. private identifyBorder;
  23298. private updateMesh;
  23299. private vertexError;
  23300. private calculateError;
  23301. }
  23302. }
  23303. declare module BABYLON {
  23304. class Polygon {
  23305. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23306. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23307. static Parse(input: string): Vector2[];
  23308. static StartingAt(x: number, y: number): Path2;
  23309. }
  23310. class PolygonMeshBuilder {
  23311. private _points;
  23312. private _outlinepoints;
  23313. private _holes;
  23314. private _name;
  23315. private _scene;
  23316. private _epoints;
  23317. private _eholes;
  23318. private _addToepoint;
  23319. constructor(name: string, contours: Path2, scene: Scene);
  23320. constructor(name: string, contours: Vector2[], scene: Scene);
  23321. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23322. build(updatable?: boolean, depth?: number): Mesh;
  23323. private addSide;
  23324. }
  23325. }
  23326. declare module BABYLON {
  23327. class BaseSubMesh {
  23328. _materialDefines: Nullable<MaterialDefines>;
  23329. _materialEffect: Nullable<Effect>;
  23330. readonly effect: Nullable<Effect>;
  23331. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23332. }
  23333. class SubMesh extends BaseSubMesh implements ICullable {
  23334. materialIndex: number;
  23335. verticesStart: number;
  23336. verticesCount: number;
  23337. indexStart: number;
  23338. indexCount: number;
  23339. linesIndexCount: number;
  23340. private _mesh;
  23341. private _renderingMesh;
  23342. private _boundingInfo;
  23343. private _linesIndexBuffer;
  23344. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23345. _trianglePlanes: Plane[];
  23346. _lastColliderTransformMatrix: Matrix;
  23347. _renderId: number;
  23348. _alphaIndex: number;
  23349. _distanceToCamera: number;
  23350. _id: number;
  23351. private _currentMaterial;
  23352. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23353. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23354. readonly IsGlobal: boolean;
  23355. /**
  23356. * Returns the submesh BoudingInfo object.
  23357. */
  23358. getBoundingInfo(): BoundingInfo;
  23359. /**
  23360. * Sets the submesh BoundingInfo.
  23361. * Return the SubMesh.
  23362. */
  23363. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23364. /**
  23365. * Returns the mesh of the current submesh.
  23366. */
  23367. getMesh(): AbstractMesh;
  23368. /**
  23369. * Returns the rendering mesh of the submesh.
  23370. */
  23371. getRenderingMesh(): Mesh;
  23372. /**
  23373. * Returns the submesh material.
  23374. */
  23375. getMaterial(): Nullable<Material>;
  23376. /**
  23377. * Sets a new updated BoundingInfo object to the submesh.
  23378. * Returns the SubMesh.
  23379. */
  23380. refreshBoundingInfo(): SubMesh;
  23381. _checkCollision(collider: Collider): boolean;
  23382. /**
  23383. * Updates the submesh BoundingInfo.
  23384. * Returns the Submesh.
  23385. */
  23386. updateBoundingInfo(world: Matrix): SubMesh;
  23387. /**
  23388. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23389. * Boolean returned.
  23390. */
  23391. isInFrustum(frustumPlanes: Plane[]): boolean;
  23392. /**
  23393. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23394. * Boolean returned.
  23395. */
  23396. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23397. /**
  23398. * Renders the submesh.
  23399. * Returns it.
  23400. */
  23401. render(enableAlphaMode: boolean): SubMesh;
  23402. /**
  23403. * Returns a new Index Buffer.
  23404. * Type returned : WebGLBuffer.
  23405. */
  23406. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23407. /**
  23408. * True is the passed Ray intersects the submesh bounding box.
  23409. * Boolean returned.
  23410. */
  23411. canIntersects(ray: Ray): boolean;
  23412. /**
  23413. * Returns an object IntersectionInfo.
  23414. */
  23415. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23416. _rebuild(): void;
  23417. /**
  23418. * Creates a new Submesh from the passed Mesh.
  23419. */
  23420. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23421. /**
  23422. * Disposes the Submesh.
  23423. * Returns nothing.
  23424. */
  23425. dispose(): void;
  23426. /**
  23427. * Creates a new Submesh from the passed parameters :
  23428. * - materialIndex (integer) : the index of the main mesh material.
  23429. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23430. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23431. * - mesh (Mesh) : the main mesh to create the submesh from.
  23432. * - renderingMesh (optional Mesh) : rendering mesh.
  23433. */
  23434. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23435. }
  23436. }
  23437. declare module BABYLON {
  23438. class TransformNode extends Node {
  23439. static BILLBOARDMODE_NONE: number;
  23440. static BILLBOARDMODE_X: number;
  23441. static BILLBOARDMODE_Y: number;
  23442. static BILLBOARDMODE_Z: number;
  23443. static BILLBOARDMODE_ALL: number;
  23444. private _forward;
  23445. private _forwardInverted;
  23446. private _up;
  23447. private _right;
  23448. private _rightInverted;
  23449. private _rotation;
  23450. private _rotationQuaternion;
  23451. protected _scaling: Vector3;
  23452. protected _isDirty: boolean;
  23453. private _transformToBoneReferal;
  23454. /**
  23455. * Set the billboard mode. Default is 0.
  23456. *
  23457. * | Value | Type | Description |
  23458. * | --- | --- | --- |
  23459. * | 0 | BILLBOARDMODE_NONE | |
  23460. * | 1 | BILLBOARDMODE_X | |
  23461. * | 2 | BILLBOARDMODE_Y | |
  23462. * | 4 | BILLBOARDMODE_Z | |
  23463. * | 7 | BILLBOARDMODE_ALL | |
  23464. *
  23465. */
  23466. billboardMode: number;
  23467. scalingDeterminant: number;
  23468. infiniteDistance: boolean;
  23469. /**
  23470. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23471. * By default the system will update normals to compensate
  23472. */
  23473. ignoreNonUniformScaling: boolean;
  23474. position: Vector3;
  23475. _poseMatrix: Matrix;
  23476. private _localWorld;
  23477. _worldMatrix: Matrix;
  23478. _worldMatrixDeterminant: number;
  23479. private _absolutePosition;
  23480. private _pivotMatrix;
  23481. private _pivotMatrixInverse;
  23482. private _postMultiplyPivotMatrix;
  23483. protected _isWorldMatrixFrozen: boolean;
  23484. /**
  23485. * An event triggered after the world matrix is updated
  23486. */
  23487. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23488. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23489. /**
  23490. * Gets a string identifying the name of the class
  23491. * @returns "TransformNode" string
  23492. */
  23493. getClassName(): string;
  23494. /**
  23495. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23496. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23497. * Default : (0.0, 0.0, 0.0)
  23498. */
  23499. rotation: Vector3;
  23500. /**
  23501. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23502. * Default : (1.0, 1.0, 1.0)
  23503. */
  23504. /**
  23505. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23506. * Default : (1.0, 1.0, 1.0)
  23507. */
  23508. scaling: Vector3;
  23509. /**
  23510. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23511. * It's null by default.
  23512. * 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)
  23513. */
  23514. rotationQuaternion: Nullable<Quaternion>;
  23515. /**
  23516. * The forward direction of that transform in world space.
  23517. */
  23518. readonly forward: Vector3;
  23519. /**
  23520. * The up direction of that transform in world space.
  23521. */
  23522. readonly up: Vector3;
  23523. /**
  23524. * The right direction of that transform in world space.
  23525. */
  23526. readonly right: Vector3;
  23527. /**
  23528. * Returns the latest update of the World matrix
  23529. * Returns a Matrix.
  23530. */
  23531. getWorldMatrix(): Matrix;
  23532. /** @hidden */
  23533. _getWorldMatrixDeterminant(): number;
  23534. /**
  23535. * Returns directly the latest state of the mesh World matrix.
  23536. * A Matrix is returned.
  23537. */
  23538. readonly worldMatrixFromCache: Matrix;
  23539. /**
  23540. * Copies the parameter passed Matrix into the mesh Pose matrix.
  23541. * Returns the TransformNode.
  23542. */
  23543. updatePoseMatrix(matrix: Matrix): TransformNode;
  23544. /**
  23545. * Returns the mesh Pose matrix.
  23546. * Returned object : Matrix
  23547. */
  23548. getPoseMatrix(): Matrix;
  23549. _isSynchronized(): boolean;
  23550. _initCache(): void;
  23551. markAsDirty(property: string): TransformNode;
  23552. /**
  23553. * Returns the current mesh absolute position.
  23554. * Returns a Vector3.
  23555. */
  23556. readonly absolutePosition: Vector3;
  23557. /**
  23558. * Sets a new matrix to apply before all other transformation
  23559. * @param matrix defines the transform matrix
  23560. * @returns the current TransformNode
  23561. */
  23562. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23563. /**
  23564. * Sets a new pivot matrix to the current node
  23565. * @param matrix defines the new pivot matrix to use
  23566. * @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
  23567. * @returns the current TransformNode
  23568. */
  23569. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23570. /**
  23571. * Returns the mesh pivot matrix.
  23572. * Default : Identity.
  23573. * A Matrix is returned.
  23574. */
  23575. getPivotMatrix(): Matrix;
  23576. /**
  23577. * Prevents the World matrix to be computed any longer.
  23578. * Returns the TransformNode.
  23579. */
  23580. freezeWorldMatrix(): TransformNode;
  23581. /**
  23582. * Allows back the World matrix computation.
  23583. * Returns the TransformNode.
  23584. */
  23585. unfreezeWorldMatrix(): this;
  23586. /**
  23587. * True if the World matrix has been frozen.
  23588. * Returns a boolean.
  23589. */
  23590. readonly isWorldMatrixFrozen: boolean;
  23591. /**
  23592. * Retuns the mesh absolute position in the World.
  23593. * Returns a Vector3.
  23594. */
  23595. getAbsolutePosition(): Vector3;
  23596. /**
  23597. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23598. * Returns the TransformNode.
  23599. */
  23600. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23601. /**
  23602. * Sets the mesh position in its local space.
  23603. * Returns the TransformNode.
  23604. */
  23605. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23606. /**
  23607. * Returns the mesh position in the local space from the current World matrix values.
  23608. * Returns a new Vector3.
  23609. */
  23610. getPositionExpressedInLocalSpace(): Vector3;
  23611. /**
  23612. * Translates the mesh along the passed Vector3 in its local space.
  23613. * Returns the TransformNode.
  23614. */
  23615. locallyTranslate(vector3: Vector3): TransformNode;
  23616. private static _lookAtVectorCache;
  23617. /**
  23618. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23619. * @param targetPoint the position (must be in same space as current mesh) to look at
  23620. * @param yawCor optional yaw (y-axis) correction in radians
  23621. * @param pitchCor optional pitch (x-axis) correction in radians
  23622. * @param rollCor optional roll (z-axis) correction in radians
  23623. * @param space the choosen space of the target
  23624. * @returns the TransformNode.
  23625. */
  23626. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23627. /**
  23628. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23629. * This Vector3 is expressed in the World space.
  23630. */
  23631. getDirection(localAxis: Vector3): Vector3;
  23632. /**
  23633. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23634. * localAxis is expressed in the mesh local space.
  23635. * result is computed in the Wordl space from the mesh World matrix.
  23636. * Returns the TransformNode.
  23637. */
  23638. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23639. /**
  23640. * Sets a new pivot point to the current node
  23641. * @param point defines the new pivot point to use
  23642. * @param space defines if the point is in world or local space (local by default)
  23643. * @returns the current TransformNode
  23644. */
  23645. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23646. /**
  23647. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23648. */
  23649. getPivotPoint(): Vector3;
  23650. /**
  23651. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23652. * Returns the TransformNode.
  23653. */
  23654. getPivotPointToRef(result: Vector3): TransformNode;
  23655. /**
  23656. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23657. */
  23658. getAbsolutePivotPoint(): Vector3;
  23659. /**
  23660. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23661. * Returns the TransformNode.
  23662. */
  23663. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23664. /**
  23665. * Defines the passed node as the parent of the current node.
  23666. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23667. * Returns the TransformNode.
  23668. */
  23669. setParent(node: Nullable<Node>): TransformNode;
  23670. private _nonUniformScaling;
  23671. readonly nonUniformScaling: boolean;
  23672. _updateNonUniformScalingState(value: boolean): boolean;
  23673. /**
  23674. * Attach the current TransformNode to another TransformNode associated with a bone
  23675. * @param bone Bone affecting the TransformNode
  23676. * @param affectedTransformNode TransformNode associated with the bone
  23677. */
  23678. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23679. detachFromBone(): TransformNode;
  23680. private static _rotationAxisCache;
  23681. /**
  23682. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23683. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23684. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23685. * The passed axis is also normalized.
  23686. * Returns the TransformNode.
  23687. */
  23688. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23689. /**
  23690. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23691. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23692. * The passed axis is also normalized.
  23693. * Returns the TransformNode.
  23694. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23695. */
  23696. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23697. /**
  23698. * Translates the mesh along the axis vector for the passed distance in the given space.
  23699. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23700. * Returns the TransformNode.
  23701. */
  23702. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23703. /**
  23704. * Adds a rotation step to the mesh current rotation.
  23705. * x, y, z are Euler angles expressed in radians.
  23706. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23707. * This means this rotation is made in the mesh local space only.
  23708. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23709. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23710. * ```javascript
  23711. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23712. * ```
  23713. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23714. * 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.
  23715. * Returns the TransformNode.
  23716. */
  23717. addRotation(x: number, y: number, z: number): TransformNode;
  23718. /**
  23719. * Computes the mesh World matrix and returns it.
  23720. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23721. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23722. * If the parameter `force`is set to `true`, the actual computation is done.
  23723. * Returns the mesh World Matrix.
  23724. */
  23725. computeWorldMatrix(force?: boolean): Matrix;
  23726. protected _afterComputeWorldMatrix(): void;
  23727. /**
  23728. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23729. * @param func: callback function to add
  23730. *
  23731. * Returns the TransformNode.
  23732. */
  23733. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23734. /**
  23735. * Removes a registered callback function.
  23736. * Returns the TransformNode.
  23737. */
  23738. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23739. /**
  23740. * Clone the current transform node
  23741. * Returns the new transform node
  23742. * @param name Name of the new clone
  23743. * @param newParent New parent for the clone
  23744. * @param doNotCloneChildren Do not clone children hierarchy
  23745. */
  23746. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23747. serialize(currentSerializationObject?: any): any;
  23748. /**
  23749. * Returns a new TransformNode object parsed from the source provided.
  23750. * The parameter `parsedMesh` is the source.
  23751. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23752. */
  23753. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23754. /**
  23755. * Releases resources associated with this transform node.
  23756. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23757. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23758. */
  23759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23760. }
  23761. }
  23762. declare module BABYLON {
  23763. class VertexBuffer {
  23764. /** @hidden */
  23765. _buffer: Buffer;
  23766. private _kind;
  23767. private _size;
  23768. private _ownsBuffer;
  23769. private _instanced;
  23770. private _instanceDivisor;
  23771. /**
  23772. * The byte type.
  23773. */
  23774. static readonly BYTE: number;
  23775. /**
  23776. * The unsigned byte type.
  23777. */
  23778. static readonly UNSIGNED_BYTE: number;
  23779. /**
  23780. * The short type.
  23781. */
  23782. static readonly SHORT: number;
  23783. /**
  23784. * The unsigned short type.
  23785. */
  23786. static readonly UNSIGNED_SHORT: number;
  23787. /**
  23788. * The integer type.
  23789. */
  23790. static readonly INT: number;
  23791. /**
  23792. * The unsigned integer type.
  23793. */
  23794. static readonly UNSIGNED_INT: number;
  23795. /**
  23796. * The float type.
  23797. */
  23798. static readonly FLOAT: number;
  23799. /**
  23800. * Gets or sets the instance divisor when in instanced mode
  23801. */
  23802. instanceDivisor: number;
  23803. /**
  23804. * Gets the byte stride.
  23805. */
  23806. readonly byteStride: number;
  23807. /**
  23808. * Gets the byte offset.
  23809. */
  23810. readonly byteOffset: number;
  23811. /**
  23812. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23813. */
  23814. readonly normalized: boolean;
  23815. /**
  23816. * Gets the data type of each component in the array.
  23817. */
  23818. readonly type: number;
  23819. /**
  23820. * Constructor
  23821. * @param engine the engine
  23822. * @param data the data to use for this vertex buffer
  23823. * @param kind the vertex buffer kind
  23824. * @param updatable whether the data is updatable
  23825. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23826. * @param stride the stride (optional)
  23827. * @param instanced whether the buffer is instanced (optional)
  23828. * @param offset the offset of the data (optional)
  23829. * @param size the number of components (optional)
  23830. * @param type the type of the component (optional)
  23831. * @param normalized whether the data contains normalized data (optional)
  23832. * @param useBytes set to true if stride and offset are in bytes (optional)
  23833. */
  23834. 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);
  23835. _rebuild(): void;
  23836. /**
  23837. * Returns the kind of the VertexBuffer (string).
  23838. */
  23839. getKind(): string;
  23840. /**
  23841. * Boolean : is the VertexBuffer updatable ?
  23842. */
  23843. isUpdatable(): boolean;
  23844. /**
  23845. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23846. */
  23847. getData(): Nullable<DataArray>;
  23848. /**
  23849. * Returns the WebGLBuffer associated to the VertexBuffer.
  23850. */
  23851. getBuffer(): Nullable<WebGLBuffer>;
  23852. /**
  23853. * Returns the stride as a multiple of the type byte length.
  23854. * DEPRECATED. Use byteStride instead.
  23855. */
  23856. getStrideSize(): number;
  23857. /**
  23858. * Returns the offset as a multiple of the type byte length.
  23859. * DEPRECATED. Use byteOffset instead.
  23860. */
  23861. getOffset(): number;
  23862. /**
  23863. * Returns the number of components per vertex attribute (integer).
  23864. */
  23865. getSize(): number;
  23866. /**
  23867. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23868. */
  23869. getIsInstanced(): boolean;
  23870. /**
  23871. * Returns the instancing divisor, zero for non-instanced (integer).
  23872. */
  23873. getInstanceDivisor(): number;
  23874. /**
  23875. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23876. * Returns the created WebGLBuffer.
  23877. */
  23878. create(data?: DataArray): void;
  23879. /**
  23880. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23881. * This function will create a new buffer if the current one is not updatable
  23882. * Returns the updated WebGLBuffer.
  23883. */
  23884. update(data: DataArray): void;
  23885. /**
  23886. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23887. * Returns the directly updated WebGLBuffer.
  23888. * @param data the new data
  23889. * @param offset the new offset
  23890. * @param useBytes set to true if the offset is in bytes
  23891. */
  23892. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23893. /**
  23894. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23895. */
  23896. dispose(): void;
  23897. /**
  23898. * Enumerates each value of this vertex buffer as numbers.
  23899. * @param count the number of values to enumerate
  23900. * @param callback the callback function called for each value
  23901. */
  23902. forEach(count: number, callback: (value: number, index: number) => void): void;
  23903. private static _PositionKind;
  23904. private static _NormalKind;
  23905. private static _TangentKind;
  23906. private static _UVKind;
  23907. private static _UV2Kind;
  23908. private static _UV3Kind;
  23909. private static _UV4Kind;
  23910. private static _UV5Kind;
  23911. private static _UV6Kind;
  23912. private static _ColorKind;
  23913. private static _MatricesIndicesKind;
  23914. private static _MatricesWeightsKind;
  23915. private static _MatricesIndicesExtraKind;
  23916. private static _MatricesWeightsExtraKind;
  23917. static readonly PositionKind: string;
  23918. static readonly NormalKind: string;
  23919. static readonly TangentKind: string;
  23920. static readonly UVKind: string;
  23921. static readonly UV2Kind: string;
  23922. static readonly UV3Kind: string;
  23923. static readonly UV4Kind: string;
  23924. static readonly UV5Kind: string;
  23925. static readonly UV6Kind: string;
  23926. static readonly ColorKind: string;
  23927. static readonly MatricesIndicesKind: string;
  23928. static readonly MatricesWeightsKind: string;
  23929. static readonly MatricesIndicesExtraKind: string;
  23930. static readonly MatricesWeightsExtraKind: string;
  23931. /**
  23932. * Deduces the stride given a kind.
  23933. * @param kind The kind string to deduce
  23934. * @returns The deduced stride
  23935. */
  23936. static DeduceStride(kind: string): number;
  23937. /**
  23938. * Gets the byte length of the given type.
  23939. * @param type the type
  23940. * @returns the number of bytes
  23941. */
  23942. static GetTypeByteLength(type: number): number;
  23943. /**
  23944. * Enumerates each value of the given parameters as numbers.
  23945. * @param data the data to enumerate
  23946. * @param byteOffset the byte offset of the data
  23947. * @param byteStride the byte stride of the data
  23948. * @param componentCount the number of components per element
  23949. * @param componentType the type of the component
  23950. * @param count the total number of components
  23951. * @param normalized whether the data is normalized
  23952. * @param callback the callback function called for each value
  23953. */
  23954. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23955. private static _GetFloatValue;
  23956. }
  23957. }
  23958. declare module BABYLON {
  23959. /**
  23960. * Defines a target to use with MorphTargetManager
  23961. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23962. */
  23963. class MorphTarget implements IAnimatable {
  23964. /** defines the name of the target */
  23965. name: string;
  23966. /**
  23967. * Gets or sets the list of animations
  23968. */
  23969. animations: Animation[];
  23970. private _scene;
  23971. private _positions;
  23972. private _normals;
  23973. private _tangents;
  23974. private _influence;
  23975. /**
  23976. * Observable raised when the influence changes
  23977. */
  23978. onInfluenceChanged: Observable<boolean>;
  23979. /**
  23980. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23981. */
  23982. influence: number;
  23983. private _animationPropertiesOverride;
  23984. /**
  23985. * Gets or sets the animation properties override
  23986. */
  23987. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23988. /**
  23989. * Creates a new MorphTarget
  23990. * @param name defines the name of the target
  23991. * @param influence defines the influence to use
  23992. */
  23993. constructor(
  23994. /** defines the name of the target */
  23995. name: string, influence?: number, scene?: Nullable<Scene>);
  23996. /**
  23997. * Gets a boolean defining if the target contains position data
  23998. */
  23999. readonly hasPositions: boolean;
  24000. /**
  24001. * Gets a boolean defining if the target contains normal data
  24002. */
  24003. readonly hasNormals: boolean;
  24004. /**
  24005. * Gets a boolean defining if the target contains tangent data
  24006. */
  24007. readonly hasTangents: boolean;
  24008. /**
  24009. * Affects position data to this target
  24010. * @param data defines the position data to use
  24011. */
  24012. setPositions(data: Nullable<FloatArray>): void;
  24013. /**
  24014. * Gets the position data stored in this target
  24015. * @returns a FloatArray containing the position data (or null if not present)
  24016. */
  24017. getPositions(): Nullable<FloatArray>;
  24018. /**
  24019. * Affects normal data to this target
  24020. * @param data defines the normal data to use
  24021. */
  24022. setNormals(data: Nullable<FloatArray>): void;
  24023. /**
  24024. * Gets the normal data stored in this target
  24025. * @returns a FloatArray containing the normal data (or null if not present)
  24026. */
  24027. getNormals(): Nullable<FloatArray>;
  24028. /**
  24029. * Affects tangent data to this target
  24030. * @param data defines the tangent data to use
  24031. */
  24032. setTangents(data: Nullable<FloatArray>): void;
  24033. /**
  24034. * Gets the tangent data stored in this target
  24035. * @returns a FloatArray containing the tangent data (or null if not present)
  24036. */
  24037. getTangents(): Nullable<FloatArray>;
  24038. /**
  24039. * Serializes the current target into a Serialization object
  24040. * @returns the serialized object
  24041. */
  24042. serialize(): any;
  24043. /**
  24044. * Creates a new target from serialized data
  24045. * @param serializationObject defines the serialized data to use
  24046. * @returns a new MorphTarget
  24047. */
  24048. static Parse(serializationObject: any): MorphTarget;
  24049. /**
  24050. * Creates a MorphTarget from mesh data
  24051. * @param mesh defines the source mesh
  24052. * @param name defines the name to use for the new target
  24053. * @param influence defines the influence to attach to the target
  24054. * @returns a new MorphTarget
  24055. */
  24056. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24057. }
  24058. }
  24059. declare module BABYLON {
  24060. /**
  24061. * This class is used to deform meshes using morphing between different targets
  24062. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24063. */
  24064. class MorphTargetManager {
  24065. private _targets;
  24066. private _targetObservable;
  24067. private _activeTargets;
  24068. private _scene;
  24069. private _influences;
  24070. private _supportsNormals;
  24071. private _supportsTangents;
  24072. private _vertexCount;
  24073. private _uniqueId;
  24074. private _tempInfluences;
  24075. /**
  24076. * Creates a new MorphTargetManager
  24077. * @param scene defines the current scene
  24078. */
  24079. constructor(scene?: Nullable<Scene>);
  24080. /**
  24081. * Gets the unique ID of this manager
  24082. */
  24083. readonly uniqueId: number;
  24084. /**
  24085. * Gets the number of vertices handled by this manager
  24086. */
  24087. readonly vertexCount: number;
  24088. /**
  24089. * Gets a boolean indicating if this manager supports morphing of normals
  24090. */
  24091. readonly supportsNormals: boolean;
  24092. /**
  24093. * Gets a boolean indicating if this manager supports morphing of tangents
  24094. */
  24095. readonly supportsTangents: boolean;
  24096. /**
  24097. * Gets the number of targets stored in this manager
  24098. */
  24099. readonly numTargets: number;
  24100. /**
  24101. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24102. */
  24103. readonly numInfluencers: number;
  24104. /**
  24105. * Gets the list of influences (one per target)
  24106. */
  24107. readonly influences: Float32Array;
  24108. /**
  24109. * Gets the active target at specified index. An active target is a target with an influence > 0
  24110. * @param index defines the index to check
  24111. * @returns the requested target
  24112. */
  24113. getActiveTarget(index: number): MorphTarget;
  24114. /**
  24115. * Gets the target at specified index
  24116. * @param index defines the index to check
  24117. * @returns the requested target
  24118. */
  24119. getTarget(index: number): MorphTarget;
  24120. /**
  24121. * Add a new target to this manager
  24122. * @param target defines the target to add
  24123. */
  24124. addTarget(target: MorphTarget): void;
  24125. /**
  24126. * Removes a target from the manager
  24127. * @param target defines the target to remove
  24128. */
  24129. removeTarget(target: MorphTarget): void;
  24130. /**
  24131. * Serializes the current manager into a Serialization object
  24132. * @returns the serialized object
  24133. */
  24134. serialize(): any;
  24135. private _syncActiveTargets;
  24136. /**
  24137. * Syncrhonize the targets with all the meshes using this morph target manager
  24138. */
  24139. synchronize(): void;
  24140. /**
  24141. * Creates a new MorphTargetManager from serialized data
  24142. * @param serializationObject defines the serialized data
  24143. * @param scene defines the hosting scene
  24144. * @returns the new MorphTargetManager
  24145. */
  24146. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24147. }
  24148. }
  24149. declare module BABYLON {
  24150. /**
  24151. * This represents the base class for particle system in Babylon.
  24152. * 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.
  24153. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24154. * @example https://doc.babylonjs.com/babylon101/particles
  24155. */
  24156. class BaseParticleSystem {
  24157. /**
  24158. * Source color is added to the destination color without alpha affecting the result.
  24159. */
  24160. static BLENDMODE_ONEONE: number;
  24161. /**
  24162. * Blend current color and particle color using particle’s alpha.
  24163. */
  24164. static BLENDMODE_STANDARD: number;
  24165. /**
  24166. * Add current color and particle color multiplied by particle’s alpha.
  24167. */
  24168. static BLENDMODE_ADD: number;
  24169. /**
  24170. * List of animations used by the particle system.
  24171. */
  24172. animations: Animation[];
  24173. /**
  24174. * The id of the Particle system.
  24175. */
  24176. id: string;
  24177. /**
  24178. * The friendly name of the Particle system.
  24179. */
  24180. name: string;
  24181. /**
  24182. * The rendering group used by the Particle system to chose when to render.
  24183. */
  24184. renderingGroupId: number;
  24185. /**
  24186. * The emitter represents the Mesh or position we are attaching the particle system to.
  24187. */
  24188. emitter: Nullable<AbstractMesh | Vector3>;
  24189. /**
  24190. * The maximum number of particles to emit per frame
  24191. */
  24192. emitRate: number;
  24193. /**
  24194. * If you want to launch only a few particles at once, that can be done, as well.
  24195. */
  24196. manualEmitCount: number;
  24197. /**
  24198. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24199. */
  24200. updateSpeed: number;
  24201. /**
  24202. * The amount of time the particle system is running (depends of the overall update speed).
  24203. */
  24204. targetStopDuration: number;
  24205. /**
  24206. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24207. */
  24208. disposeOnStop: boolean;
  24209. /**
  24210. * Minimum power of emitting particles.
  24211. */
  24212. minEmitPower: number;
  24213. /**
  24214. * Maximum power of emitting particles.
  24215. */
  24216. maxEmitPower: number;
  24217. /**
  24218. * Minimum life time of emitting particles.
  24219. */
  24220. minLifeTime: number;
  24221. /**
  24222. * Maximum life time of emitting particles.
  24223. */
  24224. maxLifeTime: number;
  24225. /**
  24226. * Minimum Size of emitting particles.
  24227. */
  24228. minSize: number;
  24229. /**
  24230. * Maximum Size of emitting particles.
  24231. */
  24232. maxSize: number;
  24233. /**
  24234. * Minimum scale of emitting particles on X axis.
  24235. */
  24236. minScaleX: number;
  24237. /**
  24238. * Maximum scale of emitting particles on X axis.
  24239. */
  24240. maxScaleX: number;
  24241. /**
  24242. * Minimum scale of emitting particles on Y axis.
  24243. */
  24244. minScaleY: number;
  24245. /**
  24246. * Maximum scale of emitting particles on Y axis.
  24247. */
  24248. maxScaleY: number;
  24249. /**
  24250. * Gets or sets the minimal initial rotation in radians.
  24251. */
  24252. minInitialRotation: number;
  24253. /**
  24254. * Gets or sets the maximal initial rotation in radians.
  24255. */
  24256. maxInitialRotation: number;
  24257. /**
  24258. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24259. */
  24260. minAngularSpeed: number;
  24261. /**
  24262. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24263. */
  24264. maxAngularSpeed: number;
  24265. /**
  24266. * The texture used to render each particle. (this can be a spritesheet)
  24267. */
  24268. particleTexture: Nullable<Texture>;
  24269. /**
  24270. * The layer mask we are rendering the particles through.
  24271. */
  24272. layerMask: number;
  24273. /**
  24274. * This can help using your own shader to render the particle system.
  24275. * The according effect will be created
  24276. */
  24277. customShader: any;
  24278. /**
  24279. * By default particle system starts as soon as they are created. This prevents the
  24280. * automatic start to happen and let you decide when to start emitting particles.
  24281. */
  24282. preventAutoStart: boolean;
  24283. /**
  24284. * Gets or sets a texture used to add random noise to particle positions
  24285. */
  24286. noiseTexture: Nullable<BaseTexture>;
  24287. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24288. noiseStrength: Vector3;
  24289. /**
  24290. * Callback triggered when the particle animation is ending.
  24291. */
  24292. onAnimationEnd: Nullable<() => void>;
  24293. /**
  24294. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24295. */
  24296. blendMode: number;
  24297. /**
  24298. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24299. * to override the particles.
  24300. */
  24301. forceDepthWrite: boolean;
  24302. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  24303. preWarmCycles: number;
  24304. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24305. preWarmStepOffset: number;
  24306. /**
  24307. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  24308. */
  24309. spriteCellChangeSpeed: number;
  24310. /**
  24311. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24312. */
  24313. startSpriteCellID: number;
  24314. /**
  24315. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24316. */
  24317. endSpriteCellID: number;
  24318. /**
  24319. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24320. */
  24321. spriteCellWidth: number;
  24322. /**
  24323. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24324. */
  24325. spriteCellHeight: number;
  24326. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24327. translationPivot: Vector2;
  24328. /** @hidden */
  24329. protected _isAnimationSheetEnabled: boolean;
  24330. /**
  24331. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  24332. */
  24333. isAnimationSheetEnabled: boolean;
  24334. /**
  24335. * You can use gravity if you want to give an orientation to your particles.
  24336. */
  24337. gravity: Vector3;
  24338. protected _colorGradients: Nullable<Array<ColorGradient>>;
  24339. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  24340. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  24341. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  24342. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  24343. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  24344. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  24345. limitVelocityDamping: number;
  24346. /**
  24347. * Gets the current list of limit velocity gradients.
  24348. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  24349. * @returns the list of limit velocity gradients
  24350. */
  24351. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  24352. /**
  24353. * Gets the current list of color gradients.
  24354. * You must use addColorGradient and removeColorGradient to udpate this list
  24355. * @returns the list of color gradients
  24356. */
  24357. getColorGradients(): Nullable<Array<ColorGradient>>;
  24358. /**
  24359. * Gets the current list of size gradients.
  24360. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24361. * @returns the list of size gradients
  24362. */
  24363. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24364. /**
  24365. * Gets the current list of life time gradients.
  24366. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24367. * @returns the list of life time gradients
  24368. */
  24369. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  24370. /**
  24371. * Gets the current list of angular speed gradients.
  24372. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24373. * @returns the list of angular speed gradients
  24374. */
  24375. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24376. /**
  24377. * Gets the current list of velocity gradients.
  24378. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24379. * @returns the list of velocity gradients
  24380. */
  24381. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24382. /**
  24383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24384. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24385. */
  24386. direction1: Vector3;
  24387. /**
  24388. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24389. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24390. */
  24391. direction2: Vector3;
  24392. /**
  24393. * 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.
  24394. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24395. */
  24396. minEmitBox: Vector3;
  24397. /**
  24398. * 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.
  24399. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24400. */
  24401. maxEmitBox: Vector3;
  24402. /**
  24403. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24404. */
  24405. color1: Color4;
  24406. /**
  24407. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24408. */
  24409. color2: Color4;
  24410. /**
  24411. * Color the particle will have at the end of its lifetime
  24412. */
  24413. colorDead: Color4;
  24414. /**
  24415. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24416. */
  24417. textureMask: Color4;
  24418. /**
  24419. * The particle emitter type defines the emitter used by the particle system.
  24420. * It can be for example box, sphere, or cone...
  24421. */
  24422. particleEmitterType: IParticleEmitterType;
  24423. /**
  24424. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24425. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24426. */
  24427. billboardMode: number;
  24428. protected _isBillboardBased: boolean;
  24429. /**
  24430. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24431. */
  24432. isBillboardBased: boolean;
  24433. /**
  24434. * The scene the particle system belongs to.
  24435. */
  24436. protected _scene: Scene;
  24437. /**
  24438. * Local cache of defines for image processing.
  24439. */
  24440. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  24441. /**
  24442. * Default configuration related to image processing available in the standard Material.
  24443. */
  24444. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24445. /**
  24446. * Gets the image processing configuration used either in this material.
  24447. */
  24448. /**
  24449. * Sets the Default image processing configuration used either in the this material.
  24450. *
  24451. * If sets to null, the scene one is in use.
  24452. */
  24453. imageProcessingConfiguration: ImageProcessingConfiguration;
  24454. /**
  24455. * Attaches a new image processing configuration to the Standard Material.
  24456. * @param configuration
  24457. */
  24458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24459. /** @hidden */
  24460. protected _reset(): void;
  24461. /**
  24462. * Instantiates a particle system.
  24463. * 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.
  24464. * @param name The name of the particle system
  24465. */
  24466. constructor(name: string);
  24467. /**
  24468. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  24469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24471. * @returns the emitter
  24472. */
  24473. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  24474. /**
  24475. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  24476. * @param radius The radius of the hemisphere to emit from
  24477. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24478. * @returns the emitter
  24479. */
  24480. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  24481. /**
  24482. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  24483. * @param radius The radius of the sphere to emit from
  24484. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24485. * @returns the emitter
  24486. */
  24487. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  24488. /**
  24489. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  24490. * @param radius The radius of the sphere to emit from
  24491. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24492. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24493. * @returns the emitter
  24494. */
  24495. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24496. /**
  24497. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  24498. * @param radius The radius of the cone to emit from
  24499. * @param angle The base angle of the cone
  24500. * @returns the emitter
  24501. */
  24502. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24503. /**
  24504. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24507. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24508. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24509. * @returns the emitter
  24510. */
  24511. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24512. }
  24513. }
  24514. declare module BABYLON {
  24515. /**
  24516. * This represents a GPU particle system in Babylon
  24517. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  24518. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  24519. */
  24520. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  24521. /**
  24522. * The layer mask we are rendering the particles through.
  24523. */
  24524. layerMask: number;
  24525. private _capacity;
  24526. private _activeCount;
  24527. private _currentActiveCount;
  24528. private _accumulatedCount;
  24529. private _renderEffect;
  24530. private _updateEffect;
  24531. private _buffer0;
  24532. private _buffer1;
  24533. private _spriteBuffer;
  24534. private _updateVAO;
  24535. private _renderVAO;
  24536. private _targetIndex;
  24537. private _sourceBuffer;
  24538. private _targetBuffer;
  24539. private _engine;
  24540. private _currentRenderId;
  24541. private _started;
  24542. private _stopped;
  24543. private _timeDelta;
  24544. private _randomTexture;
  24545. private _randomTexture2;
  24546. private _attributesStrideSize;
  24547. private _updateEffectOptions;
  24548. private _randomTextureSize;
  24549. private _actualFrame;
  24550. private readonly _rawTextureWidth;
  24551. /**
  24552. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  24553. */
  24554. static readonly IsSupported: boolean;
  24555. /**
  24556. * An event triggered when the system is disposed.
  24557. */
  24558. onDisposeObservable: Observable<GPUParticleSystem>;
  24559. /**
  24560. * Gets the maximum number of particles active at the same time.
  24561. * @returns The max number of active particles.
  24562. */
  24563. getCapacity(): number;
  24564. /**
  24565. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24566. * to override the particles.
  24567. */
  24568. forceDepthWrite: boolean;
  24569. /**
  24570. * Gets or set the number of active particles
  24571. */
  24572. activeParticleCount: number;
  24573. private _preWarmDone;
  24574. /**
  24575. * Is this system ready to be used/rendered
  24576. * @return true if the system is ready
  24577. */
  24578. isReady(): boolean;
  24579. /**
  24580. * Gets Wether the system has been started.
  24581. * @returns True if it has been started, otherwise false.
  24582. */
  24583. isStarted(): boolean;
  24584. /**
  24585. * Starts the particle system and begins to emit
  24586. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  24587. */
  24588. start(delay?: number): void;
  24589. /**
  24590. * Stops the particle system.
  24591. */
  24592. stop(): void;
  24593. /**
  24594. * Remove all active particles
  24595. */
  24596. reset(): void;
  24597. /**
  24598. * Returns the string "GPUParticleSystem"
  24599. * @returns a string containing the class name
  24600. */
  24601. getClassName(): string;
  24602. private _colorGradientsTexture;
  24603. private _removeGradient;
  24604. /**
  24605. * Adds a new color gradient
  24606. * @param gradient defines the gradient to use (between 0 and 1)
  24607. * @param color defines the color to affect to the specified gradient
  24608. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24609. * @returns the current particle system
  24610. */
  24611. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  24612. /**
  24613. * Remove a specific color gradient
  24614. * @param gradient defines the gradient to remove
  24615. * @returns the current particle system
  24616. */
  24617. removeColorGradient(gradient: number): GPUParticleSystem;
  24618. private _angularSpeedGradientsTexture;
  24619. private _sizeGradientsTexture;
  24620. private _velocityGradientsTexture;
  24621. private _limitVelocityGradientsTexture;
  24622. private _addFactorGradient;
  24623. /**
  24624. * Adds a new size gradient
  24625. * @param gradient defines the gradient to use (between 0 and 1)
  24626. * @param factor defines the size factor to affect to the specified gradient
  24627. * @returns the current particle system
  24628. */
  24629. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  24630. /**
  24631. * Remove a specific size gradient
  24632. * @param gradient defines the gradient to remove
  24633. * @returns the current particle system
  24634. */
  24635. removeSizeGradient(gradient: number): GPUParticleSystem;
  24636. /**
  24637. * Adds a new angular speed gradient
  24638. * @param gradient defines the gradient to use (between 0 and 1)
  24639. * @param factor defines the angular speed to affect to the specified gradient
  24640. * @returns the current particle system
  24641. */
  24642. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  24643. /**
  24644. * Remove a specific angular speed gradient
  24645. * @param gradient defines the gradient to remove
  24646. * @returns the current particle system
  24647. */
  24648. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  24649. /**
  24650. * Adds a new velocity gradient
  24651. * @param gradient defines the gradient to use (between 0 and 1)
  24652. * @param factor defines the velocity to affect to the specified gradient
  24653. * @returns the current particle system
  24654. */
  24655. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  24656. /**
  24657. * Remove a specific velocity gradient
  24658. * @param gradient defines the gradient to remove
  24659. * @returns the current particle system
  24660. */
  24661. removeVelocityGradient(gradient: number): GPUParticleSystem;
  24662. /**
  24663. * Adds a new limit velocity gradient
  24664. * @param gradient defines the gradient to use (between 0 and 1)
  24665. * @param factor defines the limit velocity value to affect to the specified gradient
  24666. * @returns the current particle system
  24667. */
  24668. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  24669. /**
  24670. * Remove a specific limit velocity gradient
  24671. * @param gradient defines the gradient to remove
  24672. * @returns the current particle system
  24673. */
  24674. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  24675. /**
  24676. * Instantiates a GPU particle system.
  24677. * 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.
  24678. * @param name The name of the particle system
  24679. * @param options The options used to create the system
  24680. * @param scene The scene the particle system belongs to
  24681. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24682. */
  24683. constructor(name: string, options: Partial<{
  24684. capacity: number;
  24685. randomTextureSize: number;
  24686. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  24687. protected _reset(): void;
  24688. private _createUpdateVAO;
  24689. private _createRenderVAO;
  24690. private _initialize;
  24691. /** @hidden */
  24692. _recreateUpdateEffect(): void;
  24693. /** @hidden */
  24694. _recreateRenderEffect(): void;
  24695. /**
  24696. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24697. * @param preWarm defines if we are in the pre-warmimg phase
  24698. */
  24699. animate(preWarm?: boolean): void;
  24700. private _createFactorGradientTexture;
  24701. private _createSizeGradientTexture;
  24702. private _createAngularSpeedGradientTexture;
  24703. private _createVelocityGradientTexture;
  24704. private _createColorGradientTexture;
  24705. /**
  24706. * Renders the particle system in its current state
  24707. * @param preWarm defines if the system should only update the particles but not render them
  24708. * @returns the current number of particles
  24709. */
  24710. render(preWarm?: boolean): number;
  24711. /**
  24712. * Rebuilds the particle system
  24713. */
  24714. rebuild(): void;
  24715. private _releaseBuffers;
  24716. private _releaseVAOs;
  24717. /**
  24718. * Disposes the particle system and free the associated resources
  24719. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24720. */
  24721. dispose(disposeTexture?: boolean): void;
  24722. /**
  24723. * Clones the particle system.
  24724. * @param name The name of the cloned object
  24725. * @param newEmitter The new emitter to use
  24726. * @returns the cloned particle system
  24727. */
  24728. clone(name: string, newEmitter: any): GPUParticleSystem;
  24729. /**
  24730. * Serializes the particle system to a JSON object.
  24731. * @returns the JSON object
  24732. */
  24733. serialize(): any;
  24734. /**
  24735. * Parses a JSON object to create a GPU particle system.
  24736. * @param parsedParticleSystem The JSON object to parse
  24737. * @param scene The scene to create the particle system in
  24738. * @param rootUrl The root url to use to load external dependencies like texture
  24739. * @returns the parsed GPU particle system
  24740. */
  24741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  24742. }
  24743. }
  24744. declare module BABYLON {
  24745. /**
  24746. * Interface representing a particle system in Babylon.js.
  24747. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  24748. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  24749. */
  24750. interface IParticleSystem {
  24751. /**
  24752. * List of animations used by the particle system.
  24753. */
  24754. animations: Animation[];
  24755. /**
  24756. * The id of the Particle system.
  24757. */
  24758. id: string;
  24759. /**
  24760. * The name of the Particle system.
  24761. */
  24762. name: string;
  24763. /**
  24764. * The emitter represents the Mesh or position we are attaching the particle system to.
  24765. */
  24766. emitter: Nullable<AbstractMesh | Vector3>;
  24767. /**
  24768. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24769. */
  24770. isBillboardBased: boolean;
  24771. /**
  24772. * The rendering group used by the Particle system to chose when to render.
  24773. */
  24774. renderingGroupId: number;
  24775. /**
  24776. * The layer mask we are rendering the particles through.
  24777. */
  24778. layerMask: number;
  24779. /**
  24780. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24781. */
  24782. updateSpeed: number;
  24783. /**
  24784. * The amount of time the particle system is running (depends of the overall update speed).
  24785. */
  24786. targetStopDuration: number;
  24787. /**
  24788. * The texture used to render each particle. (this can be a spritesheet)
  24789. */
  24790. particleTexture: Nullable<Texture>;
  24791. /**
  24792. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  24793. */
  24794. blendMode: number;
  24795. /**
  24796. * Minimum life time of emitting particles.
  24797. */
  24798. minLifeTime: number;
  24799. /**
  24800. * Maximum life time of emitting particles.
  24801. */
  24802. maxLifeTime: number;
  24803. /**
  24804. * Minimum Size of emitting particles.
  24805. */
  24806. minSize: number;
  24807. /**
  24808. * Maximum Size of emitting particles.
  24809. */
  24810. maxSize: number;
  24811. /**
  24812. * Minimum scale of emitting particles on X axis.
  24813. */
  24814. minScaleX: number;
  24815. /**
  24816. * Maximum scale of emitting particles on X axis.
  24817. */
  24818. maxScaleX: number;
  24819. /**
  24820. * Minimum scale of emitting particles on Y axis.
  24821. */
  24822. minScaleY: number;
  24823. /**
  24824. * Maximum scale of emitting particles on Y axis.
  24825. */
  24826. maxScaleY: number;
  24827. /**
  24828. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24829. */
  24830. color1: Color4;
  24831. /**
  24832. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24833. */
  24834. color2: Color4;
  24835. /**
  24836. * Color the particle will have at the end of its lifetime.
  24837. */
  24838. colorDead: Color4;
  24839. /**
  24840. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  24841. */
  24842. emitRate: number;
  24843. /**
  24844. * You can use gravity if you want to give an orientation to your particles.
  24845. */
  24846. gravity: Vector3;
  24847. /**
  24848. * Minimum power of emitting particles.
  24849. */
  24850. minEmitPower: number;
  24851. /**
  24852. * Maximum power of emitting particles.
  24853. */
  24854. maxEmitPower: number;
  24855. /**
  24856. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24857. */
  24858. minAngularSpeed: number;
  24859. /**
  24860. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24861. */
  24862. maxAngularSpeed: number;
  24863. /**
  24864. * Gets or sets the minimal initial rotation in radians.
  24865. */
  24866. minInitialRotation: number;
  24867. /**
  24868. * Gets or sets the maximal initial rotation in radians.
  24869. */
  24870. maxInitialRotation: number;
  24871. /**
  24872. * The particle emitter type defines the emitter used by the particle system.
  24873. * It can be for example box, sphere, or cone...
  24874. */
  24875. particleEmitterType: Nullable<IParticleEmitterType>;
  24876. /**
  24877. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  24878. */
  24879. preWarmCycles: number;
  24880. /**
  24881. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  24882. */
  24883. preWarmStepOffset: number;
  24884. /**
  24885. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  24886. */
  24887. spriteCellChangeSpeed: number;
  24888. /**
  24889. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24890. */
  24891. startSpriteCellID: number;
  24892. /**
  24893. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24894. */
  24895. endSpriteCellID: number;
  24896. /**
  24897. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24898. */
  24899. spriteCellWidth: number;
  24900. /**
  24901. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24902. */
  24903. spriteCellHeight: number;
  24904. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24905. translationPivot: Vector2;
  24906. /**
  24907. * Gets or sets a texture used to add random noise to particle positions
  24908. */
  24909. noiseTexture: Nullable<BaseTexture>;
  24910. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24911. noiseStrength: Vector3;
  24912. /**
  24913. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24914. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24915. */
  24916. billboardMode: number;
  24917. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  24918. limitVelocityDamping: number;
  24919. /**
  24920. * Gets the maximum number of particles active at the same time.
  24921. * @returns The max number of active particles.
  24922. */
  24923. getCapacity(): number;
  24924. /**
  24925. * Gets Wether the system has been started.
  24926. * @returns True if it has been started, otherwise false.
  24927. */
  24928. isStarted(): boolean;
  24929. /**
  24930. * Gets if the particle system has been started.
  24931. * @return true if the system has been started, otherwise false.
  24932. */
  24933. isStarted(): boolean;
  24934. /**
  24935. * Animates the particle system for this frame.
  24936. */
  24937. animate(): void;
  24938. /**
  24939. * Renders the particle system in its current state.
  24940. * @returns the current number of particles
  24941. */
  24942. render(): number;
  24943. /**
  24944. * Dispose the particle system and frees its associated resources.
  24945. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24946. */
  24947. dispose(disposeTexture?: boolean): void;
  24948. /**
  24949. * Clones the particle system.
  24950. * @param name The name of the cloned object
  24951. * @param newEmitter The new emitter to use
  24952. * @returns the cloned particle system
  24953. */
  24954. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  24955. /**
  24956. * Serializes the particle system to a JSON object.
  24957. * @returns the JSON object
  24958. */
  24959. serialize(): any;
  24960. /**
  24961. * Rebuild the particle system
  24962. */
  24963. rebuild(): void;
  24964. /**
  24965. * Starts the particle system and begins to emit
  24966. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  24967. */
  24968. start(delay?: number): void;
  24969. /**
  24970. * Stops the particle system.
  24971. */
  24972. stop(): void;
  24973. /**
  24974. * Remove all active particles
  24975. */
  24976. reset(): void;
  24977. /**
  24978. * Is this system ready to be used/rendered
  24979. * @return true if the system is ready
  24980. */
  24981. isReady(): boolean;
  24982. /**
  24983. * Adds a new color gradient
  24984. * @param gradient defines the gradient to use (between 0 and 1)
  24985. * @param color defines the color to affect to the specified gradient
  24986. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24987. * @returns the current particle system
  24988. */
  24989. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  24990. /**
  24991. * Remove a specific color gradient
  24992. * @param gradient defines the gradient to remove
  24993. * @returns the current particle system
  24994. */
  24995. removeColorGradient(gradient: number): IParticleSystem;
  24996. /**
  24997. * Adds a new size gradient
  24998. * @param gradient defines the gradient to use (between 0 and 1)
  24999. * @param factor defines the size factor to affect to the specified gradient
  25000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25001. * @returns the current particle system
  25002. */
  25003. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25004. /**
  25005. * Remove a specific size gradient
  25006. * @param gradient defines the gradient to remove
  25007. * @returns the current particle system
  25008. */
  25009. removeSizeGradient(gradient: number): IParticleSystem;
  25010. /**
  25011. * Gets the current list of color gradients.
  25012. * You must use addColorGradient and removeColorGradient to udpate this list
  25013. * @returns the list of color gradients
  25014. */
  25015. getColorGradients(): Nullable<Array<ColorGradient>>;
  25016. /**
  25017. * Gets the current list of size gradients.
  25018. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25019. * @returns the list of size gradients
  25020. */
  25021. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25022. /**
  25023. * Gets the current list of angular speed gradients.
  25024. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25025. * @returns the list of angular speed gradients
  25026. */
  25027. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25028. /**
  25029. * Adds a new angular speed gradient
  25030. * @param gradient defines the gradient to use (between 0 and 1)
  25031. * @param factor defines the angular speed to affect to the specified gradient
  25032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25033. * @returns the current particle system
  25034. */
  25035. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25036. /**
  25037. * Remove a specific angular speed gradient
  25038. * @param gradient defines the gradient to remove
  25039. * @returns the current particle system
  25040. */
  25041. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25042. /**
  25043. * Gets the current list of velocity gradients.
  25044. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25045. * @returns the list of velocity gradients
  25046. */
  25047. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25048. /**
  25049. * Adds a new velocity gradient
  25050. * @param gradient defines the gradient to use (between 0 and 1)
  25051. * @param factor defines the velocity to affect to the specified gradient
  25052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25053. * @returns the current particle system
  25054. */
  25055. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25056. /**
  25057. * Remove a specific velocity gradient
  25058. * @param gradient defines the gradient to remove
  25059. * @returns the current particle system
  25060. */
  25061. removeVelocityGradient(gradient: number): IParticleSystem;
  25062. /**
  25063. * Gets the current list of limit velocity gradients.
  25064. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  25065. * @returns the list of limit velocity gradients
  25066. */
  25067. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  25068. /**
  25069. * Adds a new limit velocity gradient
  25070. * @param gradient defines the gradient to use (between 0 and 1)
  25071. * @param factor defines the limit velocity to affect to the specified gradient
  25072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25073. * @returns the current particle system
  25074. */
  25075. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25076. /**
  25077. * Remove a specific limit velocity gradient
  25078. * @param gradient defines the gradient to remove
  25079. * @returns the current particle system
  25080. */
  25081. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25082. }
  25083. }
  25084. declare module BABYLON {
  25085. /**
  25086. * A particle represents one of the element emitted by a particle system.
  25087. * This is mainly define by its coordinates, direction, velocity and age.
  25088. */
  25089. class Particle {
  25090. /**
  25091. * particleSystem the particle system the particle belongs to.
  25092. */
  25093. particleSystem: ParticleSystem;
  25094. /**
  25095. * The world position of the particle in the scene.
  25096. */
  25097. position: Vector3;
  25098. /**
  25099. * The world direction of the particle in the scene.
  25100. */
  25101. direction: Vector3;
  25102. /**
  25103. * The color of the particle.
  25104. */
  25105. color: Color4;
  25106. /**
  25107. * The color change of the particle per step.
  25108. */
  25109. colorStep: Color4;
  25110. /**
  25111. * Defines how long will the life of the particle be.
  25112. */
  25113. lifeTime: number;
  25114. /**
  25115. * The current age of the particle.
  25116. */
  25117. age: number;
  25118. /**
  25119. * The current size of the particle.
  25120. */
  25121. size: number;
  25122. /**
  25123. * The current scale of the particle.
  25124. */
  25125. scale: Vector2;
  25126. /**
  25127. * The current angle of the particle.
  25128. */
  25129. angle: number;
  25130. /**
  25131. * Defines how fast is the angle changing.
  25132. */
  25133. angularSpeed: number;
  25134. /**
  25135. * Defines the cell index used by the particle to be rendered from a sprite.
  25136. */
  25137. cellIndex: number;
  25138. /** @hidden */
  25139. _initialDirection: Nullable<Vector3>;
  25140. /** @hidden */
  25141. _initialStartSpriteCellID: number;
  25142. _initialEndSpriteCellID: number;
  25143. /** @hidden */
  25144. _currentColorGradient: Nullable<ColorGradient>;
  25145. /** @hidden */
  25146. _currentColor1: Color4;
  25147. /** @hidden */
  25148. _currentColor2: Color4;
  25149. /** @hidden */
  25150. _currentSizeGradient: Nullable<FactorGradient>;
  25151. /** @hidden */
  25152. _currentSize1: number;
  25153. /** @hidden */
  25154. _currentSize2: number;
  25155. /** @hidden */
  25156. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  25157. /** @hidden */
  25158. _currentAngularSpeed1: number;
  25159. /** @hidden */
  25160. _currentAngularSpeed2: number;
  25161. /** @hidden */
  25162. _currentVelocityGradient: Nullable<FactorGradient>;
  25163. /** @hidden */
  25164. _currentVelocity1: number;
  25165. /** @hidden */
  25166. _currentVelocity2: number;
  25167. /** @hidden */
  25168. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  25169. /** @hidden */
  25170. _currentLimitVelocity1: number;
  25171. /** @hidden */
  25172. _currentLimitVelocity2: number;
  25173. /**
  25174. * Creates a new instance Particle
  25175. * @param particleSystem the particle system the particle belongs to
  25176. */
  25177. constructor(
  25178. /**
  25179. * particleSystem the particle system the particle belongs to.
  25180. */
  25181. particleSystem: ParticleSystem);
  25182. private updateCellInfoFromSystem;
  25183. /**
  25184. * Defines how the sprite cell index is updated for the particle
  25185. */
  25186. updateCellIndex(): void;
  25187. /**
  25188. * Copy the properties of particle to another one.
  25189. * @param other the particle to copy the information to.
  25190. */
  25191. copyTo(other: Particle): void;
  25192. }
  25193. }
  25194. declare module BABYLON {
  25195. /**
  25196. * This class is made for on one-liner static method to help creating particle system set.
  25197. */
  25198. class ParticleHelper {
  25199. /**
  25200. * Gets or sets base Assets URL
  25201. */
  25202. static BaseAssetsUrl: string;
  25203. /**
  25204. * Create a default particle system that you can tweak
  25205. * @param emitter defines the emitter to use
  25206. * @param capacity defines the system capacity (default is 500 particles)
  25207. * @param scene defines the hosting scene
  25208. * @returns the new Particle system
  25209. */
  25210. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene): ParticleSystem;
  25211. /**
  25212. * This is the main static method (one-liner) of this helper to create different particle systems
  25213. * @param type This string represents the type to the particle system to create
  25214. * @param scene The scene where the particle system should live
  25215. * @param gpu If the system will use gpu
  25216. * @returns the ParticleSystemSet created
  25217. */
  25218. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  25219. /**
  25220. * Static function used to export a particle system to a ParticleSystemSet variable.
  25221. * Please note that the emitter shape is not exported
  25222. * @param system defines the particle systems to export
  25223. */
  25224. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  25225. }
  25226. }
  25227. declare module BABYLON {
  25228. /**
  25229. * This represents a particle system in Babylon.
  25230. * 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.
  25231. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25232. * @example https://doc.babylonjs.com/babylon101/particles
  25233. */
  25234. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  25235. /**
  25236. * This function can be defined to provide custom update for active particles.
  25237. * This function will be called instead of regular update (age, position, color, etc.).
  25238. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  25239. */
  25240. updateFunction: (particles: Particle[]) => void;
  25241. private _emitterWorldMatrix;
  25242. /**
  25243. * This function can be defined to specify initial direction for every new particle.
  25244. * It by default use the emitterType defined function
  25245. */
  25246. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  25247. /**
  25248. * This function can be defined to specify initial position for every new particle.
  25249. * It by default use the emitterType defined function
  25250. */
  25251. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  25252. /**
  25253. * An event triggered when the system is disposed
  25254. */
  25255. onDisposeObservable: Observable<ParticleSystem>;
  25256. private _onDisposeObserver;
  25257. /**
  25258. * Sets a callback that will be triggered when the system is disposed
  25259. */
  25260. onDispose: () => void;
  25261. /**
  25262. * Get hosting scene
  25263. * @returns the scene
  25264. */
  25265. getScene(): Scene;
  25266. private _particles;
  25267. private _epsilon;
  25268. private _capacity;
  25269. private _stockParticles;
  25270. private _newPartsExcess;
  25271. private _vertexData;
  25272. private _vertexBuffer;
  25273. private _vertexBuffers;
  25274. private _spriteBuffer;
  25275. private _indexBuffer;
  25276. private _effect;
  25277. private _customEffect;
  25278. private _cachedDefines;
  25279. private _scaledColorStep;
  25280. private _colorDiff;
  25281. private _scaledDirection;
  25282. private _scaledGravity;
  25283. private _currentRenderId;
  25284. private _alive;
  25285. private _useInstancing;
  25286. private _started;
  25287. private _stopped;
  25288. private _actualFrame;
  25289. private _scaledUpdateSpeed;
  25290. private _vertexBufferSize;
  25291. /**
  25292. * 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.
  25293. */
  25294. subEmitters: ParticleSystem[];
  25295. /**
  25296. * The current active Sub-systems, this property is used by the root particle system only.
  25297. */
  25298. activeSubSystems: Array<ParticleSystem>;
  25299. private _rootParticleSystem;
  25300. /**
  25301. * Gets the current list of active particles
  25302. */
  25303. readonly particles: Particle[];
  25304. /**
  25305. * Returns the string "ParticleSystem"
  25306. * @returns a string containing the class name
  25307. */
  25308. getClassName(): string;
  25309. /**
  25310. * Instantiates a particle system.
  25311. * 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.
  25312. * @param name The name of the particle system
  25313. * @param capacity The max number of particles alive at the same time
  25314. * @param scene The scene the particle system belongs to
  25315. * @param customEffect a custom effect used to change the way particles are rendered by default
  25316. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25317. * @param epsilon Offset used to render the particles
  25318. */
  25319. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25320. private _addFactorGradient;
  25321. private _removeFactorGradient;
  25322. /**
  25323. * Adds a new life time gradient
  25324. * @param gradient defines the gradient to use (between 0 and 1)
  25325. * @param factor defines the life time factor to affect to the specified gradient
  25326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25327. * @returns the current particle system
  25328. */
  25329. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25330. /**
  25331. * Remove a specific life time gradient
  25332. * @param gradient defines the gradient to remove
  25333. * @returns the current particle system
  25334. */
  25335. removeLifeTimeGradient(gradient: number): IParticleSystem;
  25336. /**
  25337. * Adds a new size gradient
  25338. * @param gradient defines the gradient to use (between 0 and 1)
  25339. * @param factor defines the size factor to affect to the specified gradient
  25340. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25341. * @returns the current particle system
  25342. */
  25343. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25344. /**
  25345. * Remove a specific size gradient
  25346. * @param gradient defines the gradient to remove
  25347. * @returns the current particle system
  25348. */
  25349. removeSizeGradient(gradient: number): IParticleSystem;
  25350. /**
  25351. * Adds a new angular speed gradient
  25352. * @param gradient defines the gradient to use (between 0 and 1)
  25353. * @param factor defines the angular speed to affect to the specified gradient
  25354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25355. * @returns the current particle system
  25356. */
  25357. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25358. /**
  25359. * Remove a specific angular speed gradient
  25360. * @param gradient defines the gradient to remove
  25361. * @returns the current particle system
  25362. */
  25363. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25364. /**
  25365. * Adds a new velocity gradient
  25366. * @param gradient defines the gradient to use (between 0 and 1)
  25367. * @param factor defines the velocity to affect to the specified gradient
  25368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25369. * @returns the current particle system
  25370. */
  25371. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25372. /**
  25373. * Remove a specific velocity gradient
  25374. * @param gradient defines the gradient to remove
  25375. * @returns the current particle system
  25376. */
  25377. removeVelocityGradient(gradient: number): IParticleSystem;
  25378. /**
  25379. * Adds a new limit velocity gradient
  25380. * @param gradient defines the gradient to use (between 0 and 1)
  25381. * @param factor defines the limit velocity value to affect to the specified gradient
  25382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25383. * @returns the current particle system
  25384. */
  25385. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25386. /**
  25387. * Remove a specific limit velocity gradient
  25388. * @param gradient defines the gradient to remove
  25389. * @returns the current particle system
  25390. */
  25391. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25392. /**
  25393. * Adds a new color gradient
  25394. * @param gradient defines the gradient to use (between 0 and 1)
  25395. * @param color defines the color to affect to the specified gradient
  25396. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25397. */
  25398. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  25399. /**
  25400. * Remove a specific color gradient
  25401. * @param gradient defines the gradient to remove
  25402. */
  25403. removeColorGradient(gradient: number): IParticleSystem;
  25404. private _fetchR;
  25405. protected _reset(): void;
  25406. private _resetEffect;
  25407. private _createVertexBuffers;
  25408. private _createIndexBuffer;
  25409. /**
  25410. * Gets the maximum number of particles active at the same time.
  25411. * @returns The max number of active particles.
  25412. */
  25413. getCapacity(): number;
  25414. /**
  25415. * Gets whether there are still active particles in the system.
  25416. * @returns True if it is alive, otherwise false.
  25417. */
  25418. isAlive(): boolean;
  25419. /**
  25420. * Gets whether the system has been started.
  25421. * @returns True if it has been started, otherwise false.
  25422. */
  25423. isStarted(): boolean;
  25424. /**
  25425. * Starts the particle system and begins to emit
  25426. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25427. */
  25428. start(delay?: number): void;
  25429. /**
  25430. * Stops the particle system.
  25431. * @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.
  25432. */
  25433. stop(stopSubEmitters?: boolean): void;
  25434. /**
  25435. * Remove all active particles
  25436. */
  25437. reset(): void;
  25438. /**
  25439. * @hidden (for internal use only)
  25440. */
  25441. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25442. /**
  25443. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  25444. * Its lifetime will start back at 0.
  25445. */
  25446. recycleParticle: (particle: Particle) => void;
  25447. private _stopSubEmitters;
  25448. private _createParticle;
  25449. private _removeFromRoot;
  25450. private _emitFromParticle;
  25451. private _update;
  25452. /** @hidden */
  25453. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  25454. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  25455. private _getEffect;
  25456. /**
  25457. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25458. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  25459. */
  25460. animate(preWarmOnly?: boolean): void;
  25461. private _appendParticleVertices;
  25462. /**
  25463. * Rebuilds the particle system.
  25464. */
  25465. rebuild(): void;
  25466. /**
  25467. * Is this system ready to be used/rendered
  25468. * @return true if the system is ready
  25469. */
  25470. isReady(): boolean;
  25471. /**
  25472. * Renders the particle system in its current state.
  25473. * @returns the current number of particles
  25474. */
  25475. render(): number;
  25476. /**
  25477. * Disposes the particle system and free the associated resources
  25478. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25479. */
  25480. dispose(disposeTexture?: boolean): void;
  25481. /**
  25482. * Clones the particle system.
  25483. * @param name The name of the cloned object
  25484. * @param newEmitter The new emitter to use
  25485. * @returns the cloned particle system
  25486. */
  25487. clone(name: string, newEmitter: any): ParticleSystem;
  25488. /**
  25489. * Serializes the particle system to a JSON object.
  25490. * @returns the JSON object
  25491. */
  25492. serialize(): any;
  25493. /** @hidden */
  25494. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  25495. /** @hidden */
  25496. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  25497. /**
  25498. * Parses a JSON object to create a particle system.
  25499. * @param parsedParticleSystem The JSON object to parse
  25500. * @param scene The scene to create the particle system in
  25501. * @param rootUrl The root url to use to load external dependencies like texture
  25502. * @returns the Parsed particle system
  25503. */
  25504. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  25505. }
  25506. }
  25507. declare module BABYLON {
  25508. interface Engine {
  25509. /**
  25510. * Create an effect to use with particle systems.
  25511. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  25512. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  25513. * @param uniformsNames defines a list of attribute names
  25514. * @param samplers defines an array of string used to represent textures
  25515. * @param defines defines the string containing the defines to use to compile the shaders
  25516. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  25517. * @param onCompiled defines a function to call when the effect creation is successful
  25518. * @param onError defines a function to call when the effect creation has failed
  25519. * @returns the new Effect
  25520. */
  25521. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  25522. }
  25523. }
  25524. declare module BABYLON {
  25525. /**
  25526. * Represents a set of particle systems working together to create a specific effect
  25527. */
  25528. class ParticleSystemSet implements IDisposable {
  25529. private _emitterCreationOptions;
  25530. private _emitterNode;
  25531. /**
  25532. * Gets the particle system list
  25533. */
  25534. systems: IParticleSystem[];
  25535. /**
  25536. * Gets the emitter node used with this set
  25537. */
  25538. readonly emitterNode: Nullable<TransformNode>;
  25539. /**
  25540. * Creates a new emitter mesh as a sphere
  25541. * @param options defines the options used to create the sphere
  25542. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  25543. * @param scene defines the hosting scene
  25544. */
  25545. setEmitterAsSphere(options: {
  25546. diameter: number;
  25547. segments: number;
  25548. color: Color3;
  25549. }, renderingGroupId: number, scene: Scene): void;
  25550. /**
  25551. * Starts all particle systems of the set
  25552. * @param emitter defines an optional mesh to use as emitter for the particle systems
  25553. */
  25554. start(emitter?: AbstractMesh): void;
  25555. /**
  25556. * Release all associated resources
  25557. */
  25558. dispose(): void;
  25559. /**
  25560. * Serialize the set into a JSON compatible object
  25561. * @returns a JSON compatible representation of the set
  25562. */
  25563. serialize(): any;
  25564. /**
  25565. * Parse a new ParticleSystemSet from a serialized source
  25566. * @param data defines a JSON compatible representation of the set
  25567. * @param scene defines the hosting scene
  25568. * @param gpu defines if we want GPU particles or CPU particles
  25569. * @returns a new ParticleSystemSet
  25570. */
  25571. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  25572. }
  25573. }
  25574. declare module BABYLON {
  25575. /**
  25576. * Represents one particle of a solid particle system.
  25577. */
  25578. class SolidParticle {
  25579. /**
  25580. * particle global index
  25581. */
  25582. idx: number;
  25583. /**
  25584. * The color of the particle
  25585. */
  25586. color: Nullable<Color4>;
  25587. /**
  25588. * The world space position of the particle.
  25589. */
  25590. position: Vector3;
  25591. /**
  25592. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25593. */
  25594. rotation: Vector3;
  25595. /**
  25596. * The world space rotation quaternion of the particle.
  25597. */
  25598. rotationQuaternion: Nullable<Quaternion>;
  25599. /**
  25600. * The scaling of the particle.
  25601. */
  25602. scaling: Vector3;
  25603. /**
  25604. * The uvs of the particle.
  25605. */
  25606. uvs: Vector4;
  25607. /**
  25608. * The current speed of the particle.
  25609. */
  25610. velocity: Vector3;
  25611. /**
  25612. * The pivot point in the particle local space.
  25613. */
  25614. pivot: Vector3;
  25615. /**
  25616. * Must the particle be translated from its pivot point in its local space ?
  25617. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25618. * Default : false
  25619. */
  25620. translateFromPivot: boolean;
  25621. /**
  25622. * Is the particle active or not ?
  25623. */
  25624. alive: boolean;
  25625. /**
  25626. * Is the particle visible or not ?
  25627. */
  25628. isVisible: boolean;
  25629. /**
  25630. * Index of this particle in the global "positions" array (Internal use)
  25631. */
  25632. _pos: number;
  25633. /**
  25634. * Index of this particle in the global "indices" array (Internal use)
  25635. */
  25636. _ind: number;
  25637. /**
  25638. * ModelShape of this particle (Internal use)
  25639. */
  25640. _model: ModelShape;
  25641. /**
  25642. * ModelShape id of this particle
  25643. */
  25644. shapeId: number;
  25645. /**
  25646. * Index of the particle in its shape id (Internal use)
  25647. */
  25648. idxInShape: number;
  25649. /**
  25650. * Reference to the shape model BoundingInfo object (Internal use)
  25651. */
  25652. _modelBoundingInfo: BoundingInfo;
  25653. /**
  25654. * Particle BoundingInfo object (Internal use)
  25655. */
  25656. _boundingInfo: BoundingInfo;
  25657. /**
  25658. * Reference to the SPS what the particle belongs to (Internal use)
  25659. */
  25660. _sps: SolidParticleSystem;
  25661. /**
  25662. * Still set as invisible in order to skip useless computations (Internal use)
  25663. */
  25664. _stillInvisible: boolean;
  25665. /**
  25666. * Last computed particle rotation matrix
  25667. */
  25668. _rotationMatrix: number[];
  25669. /**
  25670. * Parent particle Id, if any.
  25671. * Default null.
  25672. */
  25673. parentId: Nullable<number>;
  25674. /**
  25675. * Internal global position in the SPS.
  25676. */
  25677. _globalPosition: Vector3;
  25678. /**
  25679. * Creates a Solid Particle object.
  25680. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25681. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25682. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25683. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25684. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25685. * @param shapeId (integer) is the model shape identifier in the SPS.
  25686. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25687. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25688. */
  25689. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25690. /**
  25691. * Legacy support, changed scale to scaling
  25692. */
  25693. /**
  25694. * Legacy support, changed scale to scaling
  25695. */
  25696. scale: Vector3;
  25697. /**
  25698. * Legacy support, changed quaternion to rotationQuaternion
  25699. */
  25700. /**
  25701. * Legacy support, changed quaternion to rotationQuaternion
  25702. */
  25703. quaternion: Nullable<Quaternion>;
  25704. /**
  25705. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25706. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25707. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25708. * @returns true if it intersects
  25709. */
  25710. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25711. }
  25712. /**
  25713. * Represents the shape of the model used by one particle of a solid particle system.
  25714. * SPS internal tool, don't use it manually.
  25715. */
  25716. class ModelShape {
  25717. /**
  25718. * The shape id.
  25719. */
  25720. shapeID: number;
  25721. /**
  25722. * flat array of model positions (internal use)
  25723. */
  25724. _shape: Vector3[];
  25725. /**
  25726. * flat array of model UVs (internal use)
  25727. */
  25728. _shapeUV: number[];
  25729. /**
  25730. * length of the shape in the model indices array (internal use)
  25731. */
  25732. _indicesLength: number;
  25733. /**
  25734. * Custom position function (internal use)
  25735. */
  25736. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25737. /**
  25738. * Custom vertex function (internal use)
  25739. */
  25740. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25741. /**
  25742. * 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.
  25743. * SPS internal tool, don't use it manually.
  25744. * @hidden
  25745. */
  25746. 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>);
  25747. }
  25748. /**
  25749. * Represents a Depth Sorted Particle in the solid particle system.
  25750. */
  25751. class DepthSortedParticle {
  25752. /**
  25753. * Index of the particle in the "indices" array
  25754. */
  25755. ind: number;
  25756. /**
  25757. * Length of the particle shape in the "indices" array
  25758. */
  25759. indicesLength: number;
  25760. /**
  25761. * Squared distance from the particle to the camera
  25762. */
  25763. sqDistance: number;
  25764. }
  25765. }
  25766. declare module BABYLON {
  25767. /**
  25768. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25769. *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.
  25770. * The SPS is also a particle system. It provides some methods to manage the particles.
  25771. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25772. *
  25773. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  25774. */
  25775. class SolidParticleSystem implements IDisposable {
  25776. /**
  25777. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25778. * Example : var p = SPS.particles[i];
  25779. */
  25780. particles: SolidParticle[];
  25781. /**
  25782. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25783. */
  25784. nbParticles: number;
  25785. /**
  25786. * If the particles must ever face the camera (default false). Useful for planar particles.
  25787. */
  25788. billboard: boolean;
  25789. /**
  25790. * Recompute normals when adding a shape
  25791. */
  25792. recomputeNormals: boolean;
  25793. /**
  25794. * This a counter ofr your own usage. It's not set by any SPS functions.
  25795. */
  25796. counter: number;
  25797. /**
  25798. * The SPS name. This name is also given to the underlying mesh.
  25799. */
  25800. name: string;
  25801. /**
  25802. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25803. */
  25804. mesh: Mesh;
  25805. /**
  25806. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25807. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  25808. */
  25809. vars: any;
  25810. /**
  25811. * This array is populated when the SPS is set as 'pickable'.
  25812. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25813. * Each element of this array is an object `{idx: int, faceId: int}`.
  25814. * `idx` is the picked particle index in the `SPS.particles` array
  25815. * `faceId` is the picked face index counted within this particle.
  25816. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  25817. */
  25818. pickedParticles: {
  25819. idx: number;
  25820. faceId: number;
  25821. }[];
  25822. /**
  25823. * This array is populated when `enableDepthSort` is set to true.
  25824. * Each element of this array is an instance of the class DepthSortedParticle.
  25825. */
  25826. depthSortedParticles: DepthSortedParticle[];
  25827. /**
  25828. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25829. */
  25830. _bSphereOnly: boolean;
  25831. /**
  25832. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25833. */
  25834. _bSphereRadiusFactor: number;
  25835. private _scene;
  25836. private _positions;
  25837. private _indices;
  25838. private _normals;
  25839. private _colors;
  25840. private _uvs;
  25841. private _indices32;
  25842. private _positions32;
  25843. private _normals32;
  25844. private _fixedNormal32;
  25845. private _colors32;
  25846. private _uvs32;
  25847. private _index;
  25848. private _updatable;
  25849. private _pickable;
  25850. private _isVisibilityBoxLocked;
  25851. private _alwaysVisible;
  25852. private _depthSort;
  25853. private _shapeCounter;
  25854. private _copy;
  25855. private _shape;
  25856. private _shapeUV;
  25857. private _color;
  25858. private _computeParticleColor;
  25859. private _computeParticleTexture;
  25860. private _computeParticleRotation;
  25861. private _computeParticleVertex;
  25862. private _computeBoundingBox;
  25863. private _depthSortParticles;
  25864. private _cam_axisZ;
  25865. private _cam_axisY;
  25866. private _cam_axisX;
  25867. private _axisZ;
  25868. private _camera;
  25869. private _particle;
  25870. private _camDir;
  25871. private _camInvertedPosition;
  25872. private _rotMatrix;
  25873. private _invertMatrix;
  25874. private _rotated;
  25875. private _quaternion;
  25876. private _vertex;
  25877. private _normal;
  25878. private _yaw;
  25879. private _pitch;
  25880. private _roll;
  25881. private _halfroll;
  25882. private _halfpitch;
  25883. private _halfyaw;
  25884. private _sinRoll;
  25885. private _cosRoll;
  25886. private _sinPitch;
  25887. private _cosPitch;
  25888. private _sinYaw;
  25889. private _cosYaw;
  25890. private _mustUnrotateFixedNormals;
  25891. private _minimum;
  25892. private _maximum;
  25893. private _minBbox;
  25894. private _maxBbox;
  25895. private _particlesIntersect;
  25896. private _depthSortFunction;
  25897. private _needs32Bits;
  25898. private _pivotBackTranslation;
  25899. private _scaledPivot;
  25900. private _particleHasParent;
  25901. private _parent;
  25902. /**
  25903. * Creates a SPS (Solid Particle System) object.
  25904. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25905. * @param scene (Scene) is the scene in which the SPS is added.
  25906. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25907. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25908. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25909. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25910. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25911. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25912. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25913. */
  25914. constructor(name: string, scene: Scene, options?: {
  25915. updatable?: boolean;
  25916. isPickable?: boolean;
  25917. enableDepthSort?: boolean;
  25918. particleIntersection?: boolean;
  25919. boundingSphereOnly?: boolean;
  25920. bSphereRadiusFactor?: number;
  25921. });
  25922. /**
  25923. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25924. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25925. * @returns the created mesh
  25926. */
  25927. buildMesh(): Mesh;
  25928. /**
  25929. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25930. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25931. * Thus the particles generated from `digest()` have their property `position` set yet.
  25932. * @param mesh ( Mesh ) is the mesh to be digested
  25933. * @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
  25934. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25935. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25936. * @returns the current SPS
  25937. */
  25938. digest(mesh: Mesh, options?: {
  25939. facetNb?: number;
  25940. number?: number;
  25941. delta?: number;
  25942. }): SolidParticleSystem;
  25943. private _unrotateFixedNormals;
  25944. private _resetCopy;
  25945. private _meshBuilder;
  25946. private _posToShape;
  25947. private _uvsToShapeUV;
  25948. private _addParticle;
  25949. /**
  25950. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25951. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25952. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25953. * @param nb (positive integer) the number of particles to be created from this model
  25954. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25955. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25956. * @returns the number of shapes in the system
  25957. */
  25958. addShape(mesh: Mesh, nb: number, options?: {
  25959. positionFunction?: any;
  25960. vertexFunction?: any;
  25961. }): number;
  25962. private _rebuildParticle;
  25963. /**
  25964. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25965. * @returns the SPS.
  25966. */
  25967. rebuildMesh(): SolidParticleSystem;
  25968. /**
  25969. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25970. * This method calls `updateParticle()` for each particle of the SPS.
  25971. * For an animated SPS, it is usually called within the render loop.
  25972. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25973. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25974. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25975. * @returns the SPS.
  25976. */
  25977. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25978. private _quaternionRotationYPR;
  25979. private _quaternionToRotationMatrix;
  25980. /**
  25981. * Disposes the SPS.
  25982. */
  25983. dispose(): void;
  25984. /**
  25985. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25986. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25987. * @returns the SPS.
  25988. */
  25989. refreshVisibleSize(): SolidParticleSystem;
  25990. /**
  25991. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25992. * @param size the size (float) of the visibility box
  25993. * note : this doesn't lock the SPS mesh bounding box.
  25994. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25995. */
  25996. setVisibilityBox(size: number): void;
  25997. /**
  25998. * Gets whether the SPS as always visible or not
  25999. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26000. */
  26001. /**
  26002. * Sets the SPS as always visible or not
  26003. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26004. */
  26005. isAlwaysVisible: boolean;
  26006. /**
  26007. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26008. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26009. */
  26010. /**
  26011. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26012. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26013. */
  26014. isVisibilityBoxLocked: boolean;
  26015. /**
  26016. * Tells to `setParticles()` to compute the particle rotations or not.
  26017. * Default value : true. The SPS is faster when it's set to false.
  26018. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26019. */
  26020. /**
  26021. * Gets if `setParticles()` computes the particle rotations or not.
  26022. * Default value : true. The SPS is faster when it's set to false.
  26023. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26024. */
  26025. computeParticleRotation: boolean;
  26026. /**
  26027. * Tells to `setParticles()` to compute the particle colors or not.
  26028. * Default value : true. The SPS is faster when it's set to false.
  26029. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26030. */
  26031. /**
  26032. * Gets if `setParticles()` computes the particle colors or not.
  26033. * Default value : true. The SPS is faster when it's set to false.
  26034. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26035. */
  26036. computeParticleColor: boolean;
  26037. /**
  26038. * Gets if `setParticles()` computes the particle textures or not.
  26039. * Default value : true. The SPS is faster when it's set to false.
  26040. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26041. */
  26042. computeParticleTexture: boolean;
  26043. /**
  26044. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26045. * Default value : false. The SPS is faster when it's set to false.
  26046. * Note : the particle custom vertex positions aren't stored values.
  26047. */
  26048. /**
  26049. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26050. * Default value : false. The SPS is faster when it's set to false.
  26051. * Note : the particle custom vertex positions aren't stored values.
  26052. */
  26053. computeParticleVertex: boolean;
  26054. /**
  26055. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26056. */
  26057. /**
  26058. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26059. */
  26060. computeBoundingBox: boolean;
  26061. /**
  26062. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26063. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26064. * Default : `true`
  26065. */
  26066. /**
  26067. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26068. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26069. * Default : `true`
  26070. */
  26071. depthSortParticles: boolean;
  26072. /**
  26073. * This function does nothing. It may be overwritten to set all the particle first values.
  26074. * The SPS doesn't call this function, you may have to call it by your own.
  26075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26076. */
  26077. initParticles(): void;
  26078. /**
  26079. * This function does nothing. It may be overwritten to recycle a particle.
  26080. * The SPS doesn't call this function, you may have to call it by your own.
  26081. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26082. * @param particle The particle to recycle
  26083. * @returns the recycled particle
  26084. */
  26085. recycleParticle(particle: SolidParticle): SolidParticle;
  26086. /**
  26087. * Updates a particle : this function should be overwritten by the user.
  26088. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26089. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26090. * @example : just set a particle position or velocity and recycle conditions
  26091. * @param particle The particle to update
  26092. * @returns the updated particle
  26093. */
  26094. updateParticle(particle: SolidParticle): SolidParticle;
  26095. /**
  26096. * Updates a vertex of a particle : it can be overwritten by the user.
  26097. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26098. * @param particle the current particle
  26099. * @param vertex the current index of the current particle
  26100. * @param pt the index of the current vertex in the particle shape
  26101. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26102. * @example : just set a vertex particle position
  26103. * @returns the updated vertex
  26104. */
  26105. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26106. /**
  26107. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26108. * This does nothing and may be overwritten by the user.
  26109. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26110. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26111. * @param update the boolean update value actually passed to setParticles()
  26112. */
  26113. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26114. /**
  26115. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26116. * This will be passed three parameters.
  26117. * This does nothing and may be overwritten by the user.
  26118. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26119. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26120. * @param update the boolean update value actually passed to setParticles()
  26121. */
  26122. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26123. }
  26124. }
  26125. declare module BABYLON {
  26126. interface PhysicsImpostorJoint {
  26127. mainImpostor: PhysicsImpostor;
  26128. connectedImpostor: PhysicsImpostor;
  26129. joint: PhysicsJoint;
  26130. }
  26131. class PhysicsEngine {
  26132. private _physicsPlugin;
  26133. gravity: Vector3;
  26134. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  26135. setGravity(gravity: Vector3): void;
  26136. /**
  26137. * Set the time step of the physics engine.
  26138. * default is 1/60.
  26139. * To slow it down, enter 1/600 for example.
  26140. * To speed it up, 1/30
  26141. * @param {number} newTimeStep the new timestep to apply to this world.
  26142. */
  26143. setTimeStep(newTimeStep?: number): void;
  26144. /**
  26145. * Get the time step of the physics engine.
  26146. */
  26147. getTimeStep(): number;
  26148. dispose(): void;
  26149. getPhysicsPluginName(): string;
  26150. static Epsilon: number;
  26151. private _impostors;
  26152. private _joints;
  26153. /**
  26154. * Adding a new impostor for the impostor tracking.
  26155. * This will be done by the impostor itself.
  26156. * @param {PhysicsImpostor} impostor the impostor to add
  26157. */
  26158. addImpostor(impostor: PhysicsImpostor): void;
  26159. /**
  26160. * Remove an impostor from the engine.
  26161. * This impostor and its mesh will not longer be updated by the physics engine.
  26162. * @param {PhysicsImpostor} impostor the impostor to remove
  26163. */
  26164. removeImpostor(impostor: PhysicsImpostor): void;
  26165. /**
  26166. * Add a joint to the physics engine
  26167. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  26168. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  26169. * @param {PhysicsJoint} the joint that will connect both impostors.
  26170. */
  26171. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26172. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26173. /**
  26174. * Called by the scene. no need to call it.
  26175. */
  26176. _step(delta: number): void;
  26177. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26178. getImpostors(): Array<PhysicsImpostor>;
  26179. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26180. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26181. }
  26182. interface IPhysicsEnginePlugin {
  26183. world: any;
  26184. name: string;
  26185. setGravity(gravity: Vector3): void;
  26186. setTimeStep(timeStep: number): void;
  26187. getTimeStep(): number;
  26188. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26189. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26190. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26191. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26192. removePhysicsBody(impostor: PhysicsImpostor): void;
  26193. generateJoint(joint: PhysicsImpostorJoint): void;
  26194. removeJoint(joint: PhysicsImpostorJoint): void;
  26195. isSupported(): boolean;
  26196. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26197. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26198. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26199. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26200. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26201. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26202. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26203. getBodyMass(impostor: PhysicsImpostor): number;
  26204. getBodyFriction(impostor: PhysicsImpostor): number;
  26205. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26206. getBodyRestitution(impostor: PhysicsImpostor): number;
  26207. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26208. sleepBody(impostor: PhysicsImpostor): void;
  26209. wakeUpBody(impostor: PhysicsImpostor): void;
  26210. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26211. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26212. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26213. getRadius(impostor: PhysicsImpostor): number;
  26214. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26215. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26216. dispose(): void;
  26217. }
  26218. }
  26219. declare module BABYLON {
  26220. class PhysicsHelper {
  26221. private _scene;
  26222. private _physicsEngine;
  26223. constructor(scene: Scene);
  26224. /**
  26225. * @param {Vector3} origin the origin of the explosion
  26226. * @param {number} radius the explosion radius
  26227. * @param {number} strength the explosion strength
  26228. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26229. */
  26230. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26231. /**
  26232. * @param {Vector3} origin the origin of the explosion
  26233. * @param {number} radius the explosion radius
  26234. * @param {number} strength the explosion strength
  26235. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26236. */
  26237. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26238. /**
  26239. * @param {Vector3} origin the origin of the explosion
  26240. * @param {number} radius the explosion radius
  26241. * @param {number} strength the explosion strength
  26242. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26243. */
  26244. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  26245. /**
  26246. * @param {Vector3} origin the origin of the updraft
  26247. * @param {number} radius the radius of the updraft
  26248. * @param {number} strength the strength of the updraft
  26249. * @param {number} height the height of the updraft
  26250. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  26251. */
  26252. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  26253. /**
  26254. * @param {Vector3} origin the of the vortex
  26255. * @param {number} radius the radius of the vortex
  26256. * @param {number} strength the strength of the vortex
  26257. * @param {number} height the height of the vortex
  26258. */
  26259. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  26260. }
  26261. /***** Radial explosion *****/
  26262. class PhysicsRadialExplosionEvent {
  26263. private _scene;
  26264. private _sphere;
  26265. private _sphereOptions;
  26266. private _rays;
  26267. private _dataFetched;
  26268. constructor(scene: Scene);
  26269. /**
  26270. * Returns the data related to the radial explosion event (sphere & rays).
  26271. * @returns {PhysicsRadialExplosionEventData}
  26272. */
  26273. getData(): PhysicsRadialExplosionEventData;
  26274. /**
  26275. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  26276. * @param impostor
  26277. * @param {Vector3} origin the origin of the explosion
  26278. * @param {number} radius the explosion radius
  26279. * @param {number} strength the explosion strength
  26280. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  26281. * @returns {Nullable<PhysicsForceAndContactPoint>}
  26282. */
  26283. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  26284. /**
  26285. * Disposes the sphere.
  26286. * @param {bolean} force
  26287. */
  26288. dispose(force?: boolean): void;
  26289. /*** Helpers ***/
  26290. private _prepareSphere;
  26291. private _intersectsWithSphere;
  26292. }
  26293. /***** Gravitational Field *****/
  26294. class PhysicsGravitationalFieldEvent {
  26295. private _physicsHelper;
  26296. private _scene;
  26297. private _origin;
  26298. private _radius;
  26299. private _strength;
  26300. private _falloff;
  26301. private _tickCallback;
  26302. private _sphere;
  26303. private _dataFetched;
  26304. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  26305. /**
  26306. * Returns the data related to the gravitational field event (sphere).
  26307. * @returns {PhysicsGravitationalFieldEventData}
  26308. */
  26309. getData(): PhysicsGravitationalFieldEventData;
  26310. /**
  26311. * Enables the gravitational field.
  26312. */
  26313. enable(): void;
  26314. /**
  26315. * Disables the gravitational field.
  26316. */
  26317. disable(): void;
  26318. /**
  26319. * Disposes the sphere.
  26320. * @param {bolean} force
  26321. */
  26322. dispose(force?: boolean): void;
  26323. private _tick;
  26324. }
  26325. /***** Updraft *****/
  26326. class PhysicsUpdraftEvent {
  26327. private _scene;
  26328. private _origin;
  26329. private _radius;
  26330. private _strength;
  26331. private _height;
  26332. private _updraftMode;
  26333. private _physicsEngine;
  26334. private _originTop;
  26335. private _originDirection;
  26336. private _tickCallback;
  26337. private _cylinder;
  26338. private _cylinderPosition;
  26339. private _dataFetched;
  26340. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  26341. /**
  26342. * Returns the data related to the updraft event (cylinder).
  26343. * @returns {PhysicsUpdraftEventData}
  26344. */
  26345. getData(): PhysicsUpdraftEventData;
  26346. /**
  26347. * Enables the updraft.
  26348. */
  26349. enable(): void;
  26350. /**
  26351. * Disables the cortex.
  26352. */
  26353. disable(): void;
  26354. /**
  26355. * Disposes the sphere.
  26356. * @param {bolean} force
  26357. */
  26358. dispose(force?: boolean): void;
  26359. private getImpostorForceAndContactPoint;
  26360. private _tick;
  26361. /*** Helpers ***/
  26362. private _prepareCylinder;
  26363. private _intersectsWithCylinder;
  26364. }
  26365. /***** Vortex *****/
  26366. class PhysicsVortexEvent {
  26367. private _scene;
  26368. private _origin;
  26369. private _radius;
  26370. private _strength;
  26371. private _height;
  26372. private _physicsEngine;
  26373. private _originTop;
  26374. private _centripetalForceThreshold;
  26375. private _updraftMultiplier;
  26376. private _tickCallback;
  26377. private _cylinder;
  26378. private _cylinderPosition;
  26379. private _dataFetched;
  26380. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  26381. /**
  26382. * Returns the data related to the vortex event (cylinder).
  26383. * @returns {PhysicsVortexEventData}
  26384. */
  26385. getData(): PhysicsVortexEventData;
  26386. /**
  26387. * Enables the vortex.
  26388. */
  26389. enable(): void;
  26390. /**
  26391. * Disables the cortex.
  26392. */
  26393. disable(): void;
  26394. /**
  26395. * Disposes the sphere.
  26396. * @param {bolean} force
  26397. */
  26398. dispose(force?: boolean): void;
  26399. private getImpostorForceAndContactPoint;
  26400. private _tick;
  26401. /*** Helpers ***/
  26402. private _prepareCylinder;
  26403. private _intersectsWithCylinder;
  26404. }
  26405. /***** Enums *****/
  26406. /**
  26407. * The strenght of the force in correspondence to the distance of the affected object
  26408. */
  26409. enum PhysicsRadialImpulseFalloff {
  26410. /** Defines that impulse is constant in strength across it's whole radius */
  26411. Constant = 0,
  26412. /** DEfines that impulse gets weaker if it's further from the origin */
  26413. Linear = 1
  26414. }
  26415. /**
  26416. * The strenght of the force in correspondence to the distance of the affected object
  26417. */
  26418. enum PhysicsUpdraftMode {
  26419. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  26420. Center = 0,
  26421. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  26422. Perpendicular = 1
  26423. }
  26424. /***** Data interfaces *****/
  26425. interface PhysicsForceAndContactPoint {
  26426. force: Vector3;
  26427. contactPoint: Vector3;
  26428. }
  26429. interface PhysicsRadialExplosionEventData {
  26430. sphere: Mesh;
  26431. rays: Array<Ray>;
  26432. }
  26433. interface PhysicsGravitationalFieldEventData {
  26434. sphere: Mesh;
  26435. }
  26436. interface PhysicsUpdraftEventData {
  26437. cylinder: Mesh;
  26438. }
  26439. interface PhysicsVortexEventData {
  26440. cylinder: Mesh;
  26441. }
  26442. }
  26443. declare module BABYLON {
  26444. interface PhysicsImpostorParameters {
  26445. mass: number;
  26446. friction?: number;
  26447. restitution?: number;
  26448. nativeOptions?: any;
  26449. ignoreParent?: boolean;
  26450. disableBidirectionalTransformation?: boolean;
  26451. }
  26452. interface IPhysicsEnabledObject {
  26453. position: Vector3;
  26454. rotationQuaternion: Nullable<Quaternion>;
  26455. scaling: Vector3;
  26456. rotation?: Vector3;
  26457. parent?: any;
  26458. getBoundingInfo(): BoundingInfo;
  26459. computeWorldMatrix(force: boolean): Matrix;
  26460. getWorldMatrix?(): Matrix;
  26461. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26462. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26463. getIndices?(): Nullable<IndicesArray>;
  26464. getScene?(): Scene;
  26465. getAbsolutePosition(): Vector3;
  26466. getAbsolutePivotPoint(): Vector3;
  26467. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26468. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26469. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26470. getClassName(): string;
  26471. }
  26472. class PhysicsImpostor {
  26473. object: IPhysicsEnabledObject;
  26474. type: number;
  26475. private _options;
  26476. private _scene?;
  26477. static DEFAULT_OBJECT_SIZE: Vector3;
  26478. static IDENTITY_QUATERNION: Quaternion;
  26479. private _physicsEngine;
  26480. private _physicsBody;
  26481. private _bodyUpdateRequired;
  26482. private _onBeforePhysicsStepCallbacks;
  26483. private _onAfterPhysicsStepCallbacks;
  26484. private _onPhysicsCollideCallbacks;
  26485. private _deltaPosition;
  26486. private _deltaRotation;
  26487. private _deltaRotationConjugated;
  26488. private _parent;
  26489. private _isDisposed;
  26490. private static _tmpVecs;
  26491. private static _tmpQuat;
  26492. readonly isDisposed: boolean;
  26493. mass: number;
  26494. friction: number;
  26495. restitution: number;
  26496. uniqueId: number;
  26497. private _joints;
  26498. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26499. /**
  26500. * This function will completly initialize this impostor.
  26501. * It will create a new body - but only if this mesh has no parent.
  26502. * If it has, this impostor will not be used other than to define the impostor
  26503. * of the child mesh.
  26504. */
  26505. _init(): void;
  26506. private _getPhysicsParent;
  26507. /**
  26508. * Should a new body be generated.
  26509. */
  26510. isBodyInitRequired(): boolean;
  26511. setScalingUpdated(updated: boolean): void;
  26512. /**
  26513. * Force a regeneration of this or the parent's impostor's body.
  26514. * Use under cautious - This will remove all joints already implemented.
  26515. */
  26516. forceUpdate(): void;
  26517. /**
  26518. * Gets the body that holds this impostor. Either its own, or its parent.
  26519. */
  26520. /**
  26521. * Set the physics body. Used mainly by the physics engine/plugin
  26522. */
  26523. physicsBody: any;
  26524. parent: Nullable<PhysicsImpostor>;
  26525. resetUpdateFlags(): void;
  26526. getObjectExtendSize(): Vector3;
  26527. getObjectCenter(): Vector3;
  26528. /**
  26529. * Get a specific parametes from the options parameter.
  26530. */
  26531. getParam(paramName: string): any;
  26532. /**
  26533. * Sets a specific parameter in the options given to the physics plugin
  26534. */
  26535. setParam(paramName: string, value: number): void;
  26536. /**
  26537. * Specifically change the body's mass option. Won't recreate the physics body object
  26538. */
  26539. setMass(mass: number): void;
  26540. getLinearVelocity(): Nullable<Vector3>;
  26541. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26542. getAngularVelocity(): Nullable<Vector3>;
  26543. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26544. /**
  26545. * Execute a function with the physics plugin native code.
  26546. * Provide a function the will have two variables - the world object and the physics body object.
  26547. */
  26548. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26549. /**
  26550. * Register a function that will be executed before the physics world is stepping forward.
  26551. */
  26552. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26553. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26554. /**
  26555. * Register a function that will be executed after the physics step
  26556. */
  26557. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26558. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26559. /**
  26560. * register a function that will be executed when this impostor collides against a different body.
  26561. */
  26562. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26563. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26564. private _tmpQuat;
  26565. private _tmpQuat2;
  26566. getParentsRotation(): Quaternion;
  26567. /**
  26568. * this function is executed by the physics engine.
  26569. */
  26570. beforeStep: () => void;
  26571. /**
  26572. * this function is executed by the physics engine.
  26573. */
  26574. afterStep: () => void;
  26575. /**
  26576. * Legacy collision detection event support
  26577. */
  26578. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26579. onCollide: (e: {
  26580. body: any;
  26581. }) => void;
  26582. /**
  26583. * Apply a force
  26584. */
  26585. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26586. /**
  26587. * Apply an impulse
  26588. */
  26589. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26590. /**
  26591. * A help function to create a joint.
  26592. */
  26593. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26594. /**
  26595. * Add a joint to this impostor with a different impostor.
  26596. */
  26597. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26598. /**
  26599. * Will keep this body still, in a sleep mode.
  26600. */
  26601. sleep(): PhysicsImpostor;
  26602. /**
  26603. * Wake the body up.
  26604. */
  26605. wakeUp(): PhysicsImpostor;
  26606. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26607. dispose(): void;
  26608. setDeltaPosition(position: Vector3): void;
  26609. setDeltaRotation(rotation: Quaternion): void;
  26610. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26611. getRadius(): number;
  26612. /**
  26613. * Sync a bone with this impostor
  26614. * @param bone The bone to sync to the impostor.
  26615. * @param boneMesh The mesh that the bone is influencing.
  26616. * @param jointPivot The pivot of the joint / bone in local space.
  26617. * @param distToJoint Optional distance from the impostor to the joint.
  26618. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26619. */
  26620. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26621. /**
  26622. * Sync impostor to a bone
  26623. * @param bone The bone that the impostor will be synced to.
  26624. * @param boneMesh The mesh that the bone is influencing.
  26625. * @param jointPivot The pivot of the joint / bone in local space.
  26626. * @param distToJoint Optional distance from the impostor to the joint.
  26627. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26628. * @param boneAxis Optional vector3 axis the bone is aligned with
  26629. */
  26630. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  26631. static NoImpostor: number;
  26632. static SphereImpostor: number;
  26633. static BoxImpostor: number;
  26634. static PlaneImpostor: number;
  26635. static MeshImpostor: number;
  26636. static CylinderImpostor: number;
  26637. static ParticleImpostor: number;
  26638. static HeightmapImpostor: number;
  26639. }
  26640. }
  26641. declare module BABYLON {
  26642. interface PhysicsJointData {
  26643. mainPivot?: Vector3;
  26644. connectedPivot?: Vector3;
  26645. mainAxis?: Vector3;
  26646. connectedAxis?: Vector3;
  26647. collision?: boolean;
  26648. nativeParams?: any;
  26649. }
  26650. /**
  26651. * This is a holder class for the physics joint created by the physics plugin.
  26652. * It holds a set of functions to control the underlying joint.
  26653. */
  26654. class PhysicsJoint {
  26655. type: number;
  26656. jointData: PhysicsJointData;
  26657. private _physicsJoint;
  26658. protected _physicsPlugin: IPhysicsEnginePlugin;
  26659. constructor(type: number, jointData: PhysicsJointData);
  26660. physicsJoint: any;
  26661. physicsPlugin: IPhysicsEnginePlugin;
  26662. /**
  26663. * Execute a function that is physics-plugin specific.
  26664. * @param {Function} func the function that will be executed.
  26665. * It accepts two parameters: the physics world and the physics joint.
  26666. */
  26667. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26668. static DistanceJoint: number;
  26669. static HingeJoint: number;
  26670. static BallAndSocketJoint: number;
  26671. static WheelJoint: number;
  26672. static SliderJoint: number;
  26673. static PrismaticJoint: number;
  26674. static UniversalJoint: number;
  26675. static Hinge2Joint: number;
  26676. static PointToPointJoint: number;
  26677. static SpringJoint: number;
  26678. static LockJoint: number;
  26679. }
  26680. /**
  26681. * A class representing a physics distance joint.
  26682. */
  26683. class DistanceJoint extends PhysicsJoint {
  26684. constructor(jointData: DistanceJointData);
  26685. /**
  26686. * Update the predefined distance.
  26687. */
  26688. updateDistance(maxDistance: number, minDistance?: number): void;
  26689. }
  26690. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26691. constructor(type: number, jointData: PhysicsJointData);
  26692. /**
  26693. * Set the motor values.
  26694. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26695. * @param {number} force the force to apply
  26696. * @param {number} maxForce max force for this motor.
  26697. */
  26698. setMotor(force?: number, maxForce?: number): void;
  26699. /**
  26700. * Set the motor's limits.
  26701. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26702. */
  26703. setLimit(upperLimit: number, lowerLimit?: number): void;
  26704. }
  26705. /**
  26706. * This class represents a single hinge physics joint
  26707. */
  26708. class HingeJoint extends MotorEnabledJoint {
  26709. constructor(jointData: PhysicsJointData);
  26710. /**
  26711. * Set the motor values.
  26712. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26713. * @param {number} force the force to apply
  26714. * @param {number} maxForce max force for this motor.
  26715. */
  26716. setMotor(force?: number, maxForce?: number): void;
  26717. /**
  26718. * Set the motor's limits.
  26719. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26720. */
  26721. setLimit(upperLimit: number, lowerLimit?: number): void;
  26722. }
  26723. /**
  26724. * This class represents a dual hinge physics joint (same as wheel joint)
  26725. */
  26726. class Hinge2Joint extends MotorEnabledJoint {
  26727. constructor(jointData: PhysicsJointData);
  26728. /**
  26729. * Set the motor values.
  26730. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26731. * @param {number} force the force to apply
  26732. * @param {number} maxForce max force for this motor.
  26733. * @param {motorIndex} the motor's index, 0 or 1.
  26734. */
  26735. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26736. /**
  26737. * Set the motor limits.
  26738. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26739. * @param {number} upperLimit the upper limit
  26740. * @param {number} lowerLimit lower limit
  26741. * @param {motorIndex} the motor's index, 0 or 1.
  26742. */
  26743. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26744. }
  26745. interface IMotorEnabledJoint {
  26746. physicsJoint: any;
  26747. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26748. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26749. }
  26750. interface DistanceJointData extends PhysicsJointData {
  26751. maxDistance: number;
  26752. }
  26753. interface SpringJointData extends PhysicsJointData {
  26754. length: number;
  26755. stiffness: number;
  26756. damping: number;
  26757. }
  26758. }
  26759. declare module BABYLON {
  26760. /**
  26761. * Postprocess used to generate anaglyphic rendering
  26762. */
  26763. class AnaglyphPostProcess extends PostProcess {
  26764. private _passedProcess;
  26765. /**
  26766. * Creates a new AnaglyphPostProcess
  26767. * @param name defines postprocess name
  26768. * @param options defines creation options or target ratio scale
  26769. * @param rigCameras defines cameras using this postprocess
  26770. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  26771. * @param engine defines hosting engine
  26772. * @param reusable defines if the postprocess will be reused multiple times per frame
  26773. */
  26774. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  26775. }
  26776. }
  26777. declare module BABYLON {
  26778. class BlackAndWhitePostProcess extends PostProcess {
  26779. degree: number;
  26780. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26781. }
  26782. }
  26783. declare module BABYLON {
  26784. /**
  26785. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  26786. */
  26787. class BloomEffect extends PostProcessRenderEffect {
  26788. private bloomScale;
  26789. /**
  26790. * Internal
  26791. */
  26792. _effects: Array<PostProcess>;
  26793. /**
  26794. * Internal
  26795. */
  26796. _downscale: ExtractHighlightsPostProcess;
  26797. private _blurX;
  26798. private _blurY;
  26799. private _merge;
  26800. /**
  26801. * The luminance threshold to find bright areas of the image to bloom.
  26802. */
  26803. threshold: number;
  26804. /**
  26805. * The strength of the bloom.
  26806. */
  26807. weight: number;
  26808. /**
  26809. * Specifies the size of the bloom blur kernel, relative to the final output size
  26810. */
  26811. kernel: number;
  26812. /**
  26813. * Creates a new instance of @see BloomEffect
  26814. * @param scene The scene the effect belongs to.
  26815. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  26816. * @param bloomKernel The size of the kernel to be used when applying the blur.
  26817. * @param bloomWeight The the strength of bloom.
  26818. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26819. * @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)
  26820. */
  26821. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  26822. /**
  26823. * Disposes each of the internal effects for a given camera.
  26824. * @param camera The camera to dispose the effect on.
  26825. */
  26826. disposeEffects(camera: Camera): void;
  26827. /**
  26828. * Internal
  26829. */
  26830. _updateEffects(): void;
  26831. /**
  26832. * Internal
  26833. * @returns if all the contained post processes are ready.
  26834. */
  26835. _isReady(): boolean;
  26836. }
  26837. }
  26838. declare module BABYLON {
  26839. /**
  26840. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26841. */
  26842. class BloomMergePostProcess extends PostProcess {
  26843. /** Weight of the bloom to be added to the original input. */
  26844. weight: number;
  26845. /**
  26846. * Creates a new instance of @see BloomMergePostProcess
  26847. * @param name The name of the effect.
  26848. * @param originalFromInput Post process which's input will be used for the merge.
  26849. * @param blurred Blurred highlights post process which's output will be used.
  26850. * @param weight Weight of the bloom to be added to the original input.
  26851. * @param options The required width/height ratio to downsize to before computing the render pass.
  26852. * @param camera The camera to apply the render pass to.
  26853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26854. * @param engine The engine which the post process will be applied. (default: current engine)
  26855. * @param reusable If the post process can be reused on the same frame. (default: false)
  26856. * @param textureType Type of textures used when performing the post process. (default: 0)
  26857. * @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)
  26858. */
  26859. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  26860. /** Weight of the bloom to be added to the original input. */
  26861. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26862. }
  26863. }
  26864. declare module BABYLON {
  26865. /**
  26866. * The Blur Post Process which blurs an image based on a kernel and direction.
  26867. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  26868. */
  26869. class BlurPostProcess extends PostProcess {
  26870. /** The direction in which to blur the image. */
  26871. direction: Vector2;
  26872. private blockCompilation;
  26873. protected _kernel: number;
  26874. protected _idealKernel: number;
  26875. protected _packedFloat: boolean;
  26876. private _staticDefines;
  26877. /**
  26878. * Sets the length in pixels of the blur sample region
  26879. */
  26880. /**
  26881. * Gets the length in pixels of the blur sample region
  26882. */
  26883. kernel: number;
  26884. /**
  26885. * Sets wether or not the blur needs to unpack/repack floats
  26886. */
  26887. /**
  26888. * Gets wether or not the blur is unpacking/repacking floats
  26889. */
  26890. packedFloat: boolean;
  26891. /**
  26892. * Creates a new instance BlurPostProcess
  26893. * @param name The name of the effect.
  26894. * @param direction The direction in which to blur the image.
  26895. * @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.
  26896. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26897. * @param camera The camera to apply the render pass to.
  26898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26899. * @param engine The engine which the post process will be applied. (default: current engine)
  26900. * @param reusable If the post process can be reused on the same frame. (default: false)
  26901. * @param textureType Type of textures used when performing the post process. (default: 0)
  26902. * @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)
  26903. */
  26904. constructor(name: string,
  26905. /** The direction in which to blur the image. */
  26906. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  26907. /**
  26908. * Updates the effect with the current post process compile time values and recompiles the shader.
  26909. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26910. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26911. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26912. * @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
  26913. * @param onCompiled Called when the shader has been compiled.
  26914. * @param onError Called if there is an error when compiling a shader.
  26915. */
  26916. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26917. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26918. /**
  26919. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  26920. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  26921. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  26922. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  26923. * The gaps between physical kernels are compensated for in the weighting of the samples
  26924. * @param idealKernel Ideal blur kernel.
  26925. * @return Nearest best kernel.
  26926. */
  26927. protected _nearestBestKernel(idealKernel: number): number;
  26928. /**
  26929. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  26930. * @param x The point on the Gaussian distribution to sample.
  26931. * @return the value of the Gaussian function at x.
  26932. */
  26933. protected _gaussianWeight(x: number): number;
  26934. /**
  26935. * Generates a string that can be used as a floating point number in GLSL.
  26936. * @param x Value to print.
  26937. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  26938. * @return GLSL float string.
  26939. */
  26940. protected _glslFloat(x: number, decimalFigures?: number): string;
  26941. }
  26942. }
  26943. declare module BABYLON {
  26944. /**
  26945. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  26946. */
  26947. class ChromaticAberrationPostProcess extends PostProcess {
  26948. /**
  26949. * The amount of seperation of rgb channels (default: 30)
  26950. */
  26951. aberrationAmount: number;
  26952. /**
  26953. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  26954. */
  26955. radialIntensity: number;
  26956. /**
  26957. * 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))
  26958. */
  26959. direction: Vector2;
  26960. /**
  26961. * 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))
  26962. */
  26963. centerPosition: Vector2;
  26964. /**
  26965. * Creates a new instance ChromaticAberrationPostProcess
  26966. * @param name The name of the effect.
  26967. * @param screenWidth The width of the screen to apply the effect on.
  26968. * @param screenHeight The height of the screen to apply the effect on.
  26969. * @param options The required width/height ratio to downsize to before computing the render pass.
  26970. * @param camera The camera to apply the render pass to.
  26971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26972. * @param engine The engine which the post process will be applied. (default: current engine)
  26973. * @param reusable If the post process can be reused on the same frame. (default: false)
  26974. * @param textureType Type of textures used when performing the post process. (default: 0)
  26975. * @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)
  26976. */
  26977. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26978. }
  26979. }
  26980. declare module BABYLON {
  26981. /**
  26982. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  26983. */
  26984. class CircleOfConfusionPostProcess extends PostProcess {
  26985. /**
  26986. * 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.
  26987. */
  26988. lensSize: number;
  26989. /**
  26990. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26991. */
  26992. fStop: number;
  26993. /**
  26994. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26995. */
  26996. focusDistance: number;
  26997. /**
  26998. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  26999. */
  27000. focalLength: number;
  27001. private _depthTexture;
  27002. /**
  27003. * Creates a new instance CircleOfConfusionPostProcess
  27004. * @param name The name of the effect.
  27005. * @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.
  27006. * @param options The required width/height ratio to downsize to before computing the render pass.
  27007. * @param camera The camera to apply the render pass to.
  27008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27009. * @param engine The engine which the post process will be applied. (default: current engine)
  27010. * @param reusable If the post process can be reused on the same frame. (default: false)
  27011. * @param textureType Type of textures used when performing the post process. (default: 0)
  27012. * @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)
  27013. */
  27014. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27015. /**
  27016. * 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.
  27017. */
  27018. depthTexture: RenderTargetTexture;
  27019. }
  27020. }
  27021. declare module BABYLON {
  27022. class ColorCorrectionPostProcess extends PostProcess {
  27023. private _colorTableTexture;
  27024. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27025. }
  27026. }
  27027. declare module BABYLON {
  27028. /**
  27029. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27030. * input texture to perform effects such as edge detection or sharpening
  27031. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27032. */
  27033. class ConvolutionPostProcess extends PostProcess {
  27034. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27035. kernel: number[];
  27036. /**
  27037. * Creates a new instance ConvolutionPostProcess
  27038. * @param name The name of the effect.
  27039. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27040. * @param options The required width/height ratio to downsize to before computing the render pass.
  27041. * @param camera The camera to apply the render pass to.
  27042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27043. * @param engine The engine which the post process will be applied. (default: current engine)
  27044. * @param reusable If the post process can be reused on the same frame. (default: false)
  27045. * @param textureType Type of textures used when performing the post process. (default: 0)
  27046. */
  27047. constructor(name: string,
  27048. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27049. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27050. /**
  27051. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27052. */
  27053. static EdgeDetect0Kernel: number[];
  27054. /**
  27055. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27056. */
  27057. static EdgeDetect1Kernel: number[];
  27058. /**
  27059. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27060. */
  27061. static EdgeDetect2Kernel: number[];
  27062. /**
  27063. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27064. */
  27065. static SharpenKernel: number[];
  27066. /**
  27067. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27068. */
  27069. static EmbossKernel: number[];
  27070. /**
  27071. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27072. */
  27073. static GaussianKernel: number[];
  27074. }
  27075. }
  27076. declare module BABYLON {
  27077. /**
  27078. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27079. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27080. * based on samples that have a large difference in distance than the center pixel.
  27081. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27082. */
  27083. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27084. direction: Vector2;
  27085. /**
  27086. * Creates a new instance CircleOfConfusionPostProcess
  27087. * @param name The name of the effect.
  27088. * @param scene The scene the effect belongs to.
  27089. * @param direction The direction the blur should be applied.
  27090. * @param kernel The size of the kernel used to blur.
  27091. * @param options The required width/height ratio to downsize to before computing the render pass.
  27092. * @param camera The camera to apply the render pass to.
  27093. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27094. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27096. * @param engine The engine which the post process will be applied. (default: current engine)
  27097. * @param reusable If the post process can be reused on the same frame. (default: false)
  27098. * @param textureType Type of textures used when performing the post process. (default: 0)
  27099. * @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)
  27100. */
  27101. 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);
  27102. }
  27103. }
  27104. declare module BABYLON {
  27105. /**
  27106. * Specifies the level of max blur that should be applied when using the depth of field effect
  27107. */
  27108. enum DepthOfFieldEffectBlurLevel {
  27109. /**
  27110. * Subtle blur
  27111. */
  27112. Low = 0,
  27113. /**
  27114. * Medium blur
  27115. */
  27116. Medium = 1,
  27117. /**
  27118. * Large blur
  27119. */
  27120. High = 2
  27121. }
  27122. /**
  27123. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27124. */
  27125. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27126. private _circleOfConfusion;
  27127. /**
  27128. * Internal, blurs from high to low
  27129. */
  27130. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27131. private _depthOfFieldBlurY;
  27132. private _dofMerge;
  27133. /**
  27134. * Internal post processes in depth of field effect
  27135. */
  27136. _effects: Array<PostProcess>;
  27137. /**
  27138. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27139. */
  27140. focalLength: number;
  27141. /**
  27142. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27143. */
  27144. fStop: number;
  27145. /**
  27146. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27147. */
  27148. focusDistance: number;
  27149. /**
  27150. * 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.
  27151. */
  27152. lensSize: number;
  27153. /**
  27154. * Creates a new instance DepthOfFieldEffect
  27155. * @param scene The scene the effect belongs to.
  27156. * @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.
  27157. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27158. * @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)
  27159. */
  27160. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27161. /**
  27162. * 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.
  27163. */
  27164. depthTexture: RenderTargetTexture;
  27165. /**
  27166. * Disposes each of the internal effects for a given camera.
  27167. * @param camera The camera to dispose the effect on.
  27168. */
  27169. disposeEffects(camera: Camera): void;
  27170. /**
  27171. * Internal
  27172. */
  27173. _updateEffects(): void;
  27174. /**
  27175. * Internal
  27176. * @returns if all the contained post processes are ready.
  27177. */
  27178. _isReady(): boolean;
  27179. }
  27180. }
  27181. declare module BABYLON {
  27182. /**
  27183. * Options to be set when merging outputs from the default pipeline.
  27184. */
  27185. class DepthOfFieldMergePostProcessOptions {
  27186. /**
  27187. * The original image to merge on top of
  27188. */
  27189. originalFromInput: PostProcess;
  27190. /**
  27191. * Parameters to perform the merge of the depth of field effect
  27192. */
  27193. depthOfField?: {
  27194. circleOfConfusion: PostProcess;
  27195. blurSteps: Array<PostProcess>;
  27196. };
  27197. /**
  27198. * Parameters to perform the merge of bloom effect
  27199. */
  27200. bloom?: {
  27201. blurred: PostProcess;
  27202. weight: number;
  27203. };
  27204. }
  27205. /**
  27206. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27207. */
  27208. class DepthOfFieldMergePostProcess extends PostProcess {
  27209. private blurSteps;
  27210. /**
  27211. * Creates a new instance of DepthOfFieldMergePostProcess
  27212. * @param name The name of the effect.
  27213. * @param originalFromInput Post process which's input will be used for the merge.
  27214. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27215. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27216. * @param options The required width/height ratio to downsize to before computing the render pass.
  27217. * @param camera The camera to apply the render pass to.
  27218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27219. * @param engine The engine which the post process will be applied. (default: current engine)
  27220. * @param reusable If the post process can be reused on the same frame. (default: false)
  27221. * @param textureType Type of textures used when performing the post process. (default: 0)
  27222. * @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)
  27223. */
  27224. 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);
  27225. /**
  27226. * Updates the effect with the current post process compile time values and recompiles the shader.
  27227. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27228. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27229. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27230. * @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
  27231. * @param onCompiled Called when the shader has been compiled.
  27232. * @param onError Called if there is an error when compiling a shader.
  27233. */
  27234. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27235. }
  27236. }
  27237. declare module BABYLON {
  27238. class DisplayPassPostProcess extends PostProcess {
  27239. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27240. }
  27241. }
  27242. declare module BABYLON {
  27243. /**
  27244. * 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.
  27245. */
  27246. class ExtractHighlightsPostProcess extends PostProcess {
  27247. /**
  27248. * The luminance threshold, pixels below this value will be set to black.
  27249. */
  27250. threshold: number;
  27251. /**
  27252. * Internal
  27253. */
  27254. _exposure: number;
  27255. /**
  27256. * Post process which has the input texture to be used when performing highlight extraction
  27257. */
  27258. _inputPostProcess: Nullable<PostProcess>;
  27259. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27260. }
  27261. }
  27262. declare module BABYLON {
  27263. class FilterPostProcess extends PostProcess {
  27264. kernelMatrix: Matrix;
  27265. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27266. }
  27267. }
  27268. declare module BABYLON {
  27269. class FxaaPostProcess extends PostProcess {
  27270. texelWidth: number;
  27271. texelHeight: number;
  27272. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27273. private _getDefines;
  27274. }
  27275. }
  27276. declare module BABYLON {
  27277. /**
  27278. * The GrainPostProcess adds noise to the image at mid luminance levels
  27279. */
  27280. class GrainPostProcess extends PostProcess {
  27281. /**
  27282. * The intensity of the grain added (default: 30)
  27283. */
  27284. intensity: number;
  27285. /**
  27286. * If the grain should be randomized on every frame
  27287. */
  27288. animated: boolean;
  27289. /**
  27290. * Creates a new instance of @see GrainPostProcess
  27291. * @param name The name of the effect.
  27292. * @param options The required width/height ratio to downsize to before computing the render pass.
  27293. * @param camera The camera to apply the render pass to.
  27294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27295. * @param engine The engine which the post process will be applied. (default: current engine)
  27296. * @param reusable If the post process can be reused on the same frame. (default: false)
  27297. * @param textureType Type of textures used when performing the post process. (default: 0)
  27298. * @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)
  27299. */
  27300. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27301. }
  27302. }
  27303. declare module BABYLON {
  27304. class HighlightsPostProcess extends PostProcess {
  27305. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27306. }
  27307. }
  27308. declare module BABYLON {
  27309. class ImageProcessingPostProcess extends PostProcess {
  27310. /**
  27311. * Default configuration related to image processing available in the PBR Material.
  27312. */
  27313. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27314. /**
  27315. * Gets the image processing configuration used either in this material.
  27316. */
  27317. /**
  27318. * Sets the Default image processing configuration used either in the this material.
  27319. *
  27320. * If sets to null, the scene one is in use.
  27321. */
  27322. imageProcessingConfiguration: ImageProcessingConfiguration;
  27323. /**
  27324. * Keep track of the image processing observer to allow dispose and replace.
  27325. */
  27326. private _imageProcessingObserver;
  27327. /**
  27328. * Attaches a new image processing configuration to the PBR Material.
  27329. * @param configuration
  27330. */
  27331. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27332. /**
  27333. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27334. */
  27335. /**
  27336. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27337. */
  27338. colorCurves: Nullable<ColorCurves>;
  27339. /**
  27340. * Gets wether the color curves effect is enabled.
  27341. */
  27342. /**
  27343. * Sets wether the color curves effect is enabled.
  27344. */
  27345. colorCurvesEnabled: boolean;
  27346. /**
  27347. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27348. */
  27349. /**
  27350. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27351. */
  27352. colorGradingTexture: Nullable<BaseTexture>;
  27353. /**
  27354. * Gets wether the color grading effect is enabled.
  27355. */
  27356. /**
  27357. * Gets wether the color grading effect is enabled.
  27358. */
  27359. colorGradingEnabled: boolean;
  27360. /**
  27361. * Gets exposure used in the effect.
  27362. */
  27363. /**
  27364. * Sets exposure used in the effect.
  27365. */
  27366. exposure: number;
  27367. /**
  27368. * Gets wether tonemapping is enabled or not.
  27369. */
  27370. /**
  27371. * Sets wether tonemapping is enabled or not
  27372. */
  27373. toneMappingEnabled: boolean;
  27374. /**
  27375. * Gets contrast used in the effect.
  27376. */
  27377. /**
  27378. * Sets contrast used in the effect.
  27379. */
  27380. contrast: number;
  27381. /**
  27382. * Gets Vignette stretch size.
  27383. */
  27384. /**
  27385. * Sets Vignette stretch size.
  27386. */
  27387. vignetteStretch: number;
  27388. /**
  27389. * Gets Vignette centre X Offset.
  27390. */
  27391. /**
  27392. * Sets Vignette centre X Offset.
  27393. */
  27394. vignetteCentreX: number;
  27395. /**
  27396. * Gets Vignette centre Y Offset.
  27397. */
  27398. /**
  27399. * Sets Vignette centre Y Offset.
  27400. */
  27401. vignetteCentreY: number;
  27402. /**
  27403. * Gets Vignette weight or intensity of the vignette effect.
  27404. */
  27405. /**
  27406. * Sets Vignette weight or intensity of the vignette effect.
  27407. */
  27408. vignetteWeight: number;
  27409. /**
  27410. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27411. * if vignetteEnabled is set to true.
  27412. */
  27413. /**
  27414. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27415. * if vignetteEnabled is set to true.
  27416. */
  27417. vignetteColor: Color4;
  27418. /**
  27419. * Gets Camera field of view used by the Vignette effect.
  27420. */
  27421. /**
  27422. * Sets Camera field of view used by the Vignette effect.
  27423. */
  27424. vignetteCameraFov: number;
  27425. /**
  27426. * Gets the vignette blend mode allowing different kind of effect.
  27427. */
  27428. /**
  27429. * Sets the vignette blend mode allowing different kind of effect.
  27430. */
  27431. vignetteBlendMode: number;
  27432. /**
  27433. * Gets wether the vignette effect is enabled.
  27434. */
  27435. /**
  27436. * Sets wether the vignette effect is enabled.
  27437. */
  27438. vignetteEnabled: boolean;
  27439. private _fromLinearSpace;
  27440. /**
  27441. * Gets wether the input of the processing is in Gamma or Linear Space.
  27442. */
  27443. /**
  27444. * Sets wether the input of the processing is in Gamma or Linear Space.
  27445. */
  27446. fromLinearSpace: boolean;
  27447. /**
  27448. * Defines cache preventing GC.
  27449. */
  27450. private _defines;
  27451. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27452. getClassName(): string;
  27453. protected _updateParameters(): void;
  27454. dispose(camera?: Camera): void;
  27455. }
  27456. }
  27457. declare module BABYLON {
  27458. class PassPostProcess extends PostProcess {
  27459. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27460. }
  27461. }
  27462. declare module BABYLON {
  27463. type PostProcessOptions = {
  27464. width: number;
  27465. height: number;
  27466. };
  27467. /**
  27468. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27469. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27470. */
  27471. class PostProcess {
  27472. /** Name of the PostProcess. */
  27473. name: string;
  27474. /**
  27475. * Width of the texture to apply the post process on
  27476. */
  27477. width: number;
  27478. /**
  27479. * Height of the texture to apply the post process on
  27480. */
  27481. height: number;
  27482. /**
  27483. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27484. */
  27485. _outputTexture: Nullable<InternalTexture>;
  27486. /**
  27487. * Sampling mode used by the shader
  27488. * See https://doc.babylonjs.com/classes/3.1/texture
  27489. */
  27490. renderTargetSamplingMode: number;
  27491. /**
  27492. * Clear color to use when screen clearing
  27493. */
  27494. clearColor: Color4;
  27495. /**
  27496. * If the buffer needs to be cleared before applying the post process. (default: true)
  27497. * Should be set to false if shader will overwrite all previous pixels.
  27498. */
  27499. autoClear: boolean;
  27500. /**
  27501. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27502. */
  27503. alphaMode: number;
  27504. /**
  27505. * Sets the setAlphaBlendConstants of the babylon engine
  27506. */
  27507. alphaConstants: Color4;
  27508. /**
  27509. * Animations to be used for the post processing
  27510. */
  27511. animations: Animation[];
  27512. /**
  27513. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27514. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27515. */
  27516. enablePixelPerfectMode: boolean;
  27517. /**
  27518. * Force the postprocess to be applied without taking in account viewport
  27519. */
  27520. forceFullscreenViewport: boolean;
  27521. /**
  27522. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27523. *
  27524. * | Value | Type | Description |
  27525. * | ----- | ----------------------------------- | ----------- |
  27526. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27527. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27528. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27529. *
  27530. */
  27531. scaleMode: number;
  27532. /**
  27533. * Force textures to be a power of two (default: false)
  27534. */
  27535. alwaysForcePOT: boolean;
  27536. /**
  27537. * Number of sample textures (default: 1)
  27538. */
  27539. samples: number;
  27540. /**
  27541. * Modify the scale of the post process to be the same as the viewport (default: false)
  27542. */
  27543. adaptScaleToCurrentViewport: boolean;
  27544. private _camera;
  27545. private _scene;
  27546. private _engine;
  27547. private _options;
  27548. private _reusable;
  27549. private _textureType;
  27550. /**
  27551. * Smart array of input and output textures for the post process.
  27552. */
  27553. _textures: SmartArray<InternalTexture>;
  27554. /**
  27555. * The index in _textures that corresponds to the output texture.
  27556. */
  27557. _currentRenderTextureInd: number;
  27558. private _effect;
  27559. private _samplers;
  27560. private _fragmentUrl;
  27561. private _vertexUrl;
  27562. private _parameters;
  27563. private _scaleRatio;
  27564. protected _indexParameters: any;
  27565. private _shareOutputWithPostProcess;
  27566. private _texelSize;
  27567. private _forcedOutputTexture;
  27568. /**
  27569. * An event triggered when the postprocess is activated.
  27570. */
  27571. onActivateObservable: Observable<Camera>;
  27572. private _onActivateObserver;
  27573. /**
  27574. * A function that is added to the onActivateObservable
  27575. */
  27576. onActivate: Nullable<(camera: Camera) => void>;
  27577. /**
  27578. * An event triggered when the postprocess changes its size.
  27579. */
  27580. onSizeChangedObservable: Observable<PostProcess>;
  27581. private _onSizeChangedObserver;
  27582. /**
  27583. * A function that is added to the onSizeChangedObservable
  27584. */
  27585. onSizeChanged: (postProcess: PostProcess) => void;
  27586. /**
  27587. * An event triggered when the postprocess applies its effect.
  27588. */
  27589. onApplyObservable: Observable<Effect>;
  27590. private _onApplyObserver;
  27591. /**
  27592. * A function that is added to the onApplyObservable
  27593. */
  27594. onApply: (effect: Effect) => void;
  27595. /**
  27596. * An event triggered before rendering the postprocess
  27597. */
  27598. onBeforeRenderObservable: Observable<Effect>;
  27599. private _onBeforeRenderObserver;
  27600. /**
  27601. * A function that is added to the onBeforeRenderObservable
  27602. */
  27603. onBeforeRender: (effect: Effect) => void;
  27604. /**
  27605. * An event triggered after rendering the postprocess
  27606. */
  27607. onAfterRenderObservable: Observable<Effect>;
  27608. private _onAfterRenderObserver;
  27609. /**
  27610. * A function that is added to the onAfterRenderObservable
  27611. */
  27612. onAfterRender: (efect: Effect) => void;
  27613. /**
  27614. * 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
  27615. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27616. */
  27617. inputTexture: InternalTexture;
  27618. /**
  27619. * Gets the camera which post process is applied to.
  27620. * @returns The camera the post process is applied to.
  27621. */
  27622. getCamera(): Camera;
  27623. /**
  27624. * Gets the texel size of the postprocess.
  27625. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27626. */
  27627. readonly texelSize: Vector2;
  27628. /**
  27629. * Creates a new instance PostProcess
  27630. * @param name The name of the PostProcess.
  27631. * @param fragmentUrl The url of the fragment shader to be used.
  27632. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27633. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27634. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27635. * @param camera The camera to apply the render pass to.
  27636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27637. * @param engine The engine which the post process will be applied. (default: current engine)
  27638. * @param reusable If the post process can be reused on the same frame. (default: false)
  27639. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27640. * @param textureType Type of textures used when performing the post process. (default: 0)
  27641. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27642. * @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
  27643. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  27644. */
  27645. constructor(
  27646. /** Name of the PostProcess. */
  27647. 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);
  27648. /**
  27649. * Gets the engine which this post process belongs to.
  27650. * @returns The engine the post process was enabled with.
  27651. */
  27652. getEngine(): Engine;
  27653. /**
  27654. * The effect that is created when initializing the post process.
  27655. * @returns The created effect corrisponding the the postprocess.
  27656. */
  27657. getEffect(): Effect;
  27658. /**
  27659. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27660. * @param postProcess The post process to share the output with.
  27661. * @returns This post process.
  27662. */
  27663. shareOutputWith(postProcess: PostProcess): PostProcess;
  27664. /**
  27665. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27666. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27667. */
  27668. useOwnOutput(): void;
  27669. /**
  27670. * Updates the effect with the current post process compile time values and recompiles the shader.
  27671. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27672. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27673. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27674. * @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
  27675. * @param onCompiled Called when the shader has been compiled.
  27676. * @param onError Called if there is an error when compiling a shader.
  27677. */
  27678. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27679. /**
  27680. * The post process is reusable if it can be used multiple times within one frame.
  27681. * @returns If the post process is reusable
  27682. */
  27683. isReusable(): boolean;
  27684. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27685. markTextureDirty(): void;
  27686. /**
  27687. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27688. * 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.
  27689. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27690. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27691. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27692. * @returns The target texture that was bound to be written to.
  27693. */
  27694. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27695. /**
  27696. * If the post process is supported.
  27697. */
  27698. readonly isSupported: boolean;
  27699. /**
  27700. * The aspect ratio of the output texture.
  27701. */
  27702. readonly aspectRatio: number;
  27703. /**
  27704. * Get a value indicating if the post-process is ready to be used
  27705. * @returns true if the post-process is ready (shader is compiled)
  27706. */
  27707. isReady(): boolean;
  27708. /**
  27709. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27710. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  27711. */
  27712. apply(): Nullable<Effect>;
  27713. private _disposeTextures;
  27714. /**
  27715. * Disposes the post process.
  27716. * @param camera The camera to dispose the post process on.
  27717. */
  27718. dispose(camera?: Camera): void;
  27719. }
  27720. }
  27721. declare module BABYLON {
  27722. /**
  27723. * PostProcessManager is used to manage one or more post processes or post process pipelines
  27724. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27725. */
  27726. class PostProcessManager {
  27727. private _scene;
  27728. private _indexBuffer;
  27729. private _vertexBuffers;
  27730. /**
  27731. * Creates a new instance PostProcess
  27732. * @param scene The scene that the post process is associated with.
  27733. */
  27734. constructor(scene: Scene);
  27735. private _prepareBuffers;
  27736. private _buildIndexBuffer;
  27737. /**
  27738. * Rebuilds the vertex buffers of the manager.
  27739. */
  27740. _rebuild(): void;
  27741. /**
  27742. * Prepares a frame to be run through a post process.
  27743. * @param sourceTexture The input texture to the post procesess. (default: null)
  27744. * @param postProcesses An array of post processes to be run. (default: null)
  27745. * @returns True if the post processes were able to be run.
  27746. */
  27747. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  27748. /**
  27749. * Manually render a set of post processes to a texture.
  27750. * @param postProcesses An array of post processes to be run.
  27751. * @param targetTexture The target texture to render to.
  27752. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  27753. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  27754. * @param lodLevel defines which lod of the texture to render to
  27755. */
  27756. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  27757. /**
  27758. * Finalize the result of the output of the postprocesses.
  27759. * @param doNotPresent If true the result will not be displayed to the screen.
  27760. * @param targetTexture The target texture to render to.
  27761. * @param faceIndex The index of the face to bind the target texture to.
  27762. * @param postProcesses The array of post processes to render.
  27763. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  27764. */
  27765. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  27766. /**
  27767. * Disposes of the post process manager.
  27768. */
  27769. dispose(): void;
  27770. }
  27771. }
  27772. declare module BABYLON {
  27773. class RefractionPostProcess extends PostProcess {
  27774. color: Color3;
  27775. depth: number;
  27776. colorLevel: number;
  27777. private _refTexture;
  27778. private _ownRefractionTexture;
  27779. /**
  27780. * Gets or sets the refraction texture
  27781. * Please note that you are responsible for disposing the texture if you set it manually
  27782. */
  27783. refractionTexture: Texture;
  27784. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27785. dispose(camera: Camera): void;
  27786. }
  27787. }
  27788. declare module BABYLON {
  27789. /**
  27790. * The SharpenPostProcess applies a sharpen kernel to every pixel
  27791. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27792. */
  27793. class SharpenPostProcess extends PostProcess {
  27794. /**
  27795. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  27796. */
  27797. colorAmount: number;
  27798. /**
  27799. * How much sharpness should be applied (default: 0.3)
  27800. */
  27801. edgeAmount: number;
  27802. /**
  27803. * Creates a new instance ConvolutionPostProcess
  27804. * @param name The name of the effect.
  27805. * @param options The required width/height ratio to downsize to before computing the render pass.
  27806. * @param camera The camera to apply the render pass to.
  27807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27808. * @param engine The engine which the post process will be applied. (default: current engine)
  27809. * @param reusable If the post process can be reused on the same frame. (default: false)
  27810. * @param textureType Type of textures used when performing the post process. (default: 0)
  27811. * @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)
  27812. */
  27813. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27814. }
  27815. }
  27816. declare module BABYLON {
  27817. class StereoscopicInterlacePostProcess extends PostProcess {
  27818. private _stepSize;
  27819. private _passedProcess;
  27820. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27821. }
  27822. }
  27823. declare module BABYLON {
  27824. /** Defines operator used for tonemapping */
  27825. enum TonemappingOperator {
  27826. /** Hable */
  27827. Hable = 0,
  27828. /** Reinhard */
  27829. Reinhard = 1,
  27830. /** HejiDawson */
  27831. HejiDawson = 2,
  27832. /** Photographic */
  27833. Photographic = 3
  27834. }
  27835. /**
  27836. * Defines a post process to apply tone mapping
  27837. */
  27838. class TonemapPostProcess extends PostProcess {
  27839. private _operator;
  27840. /** Defines the required exposure adjustement */
  27841. exposureAdjustment: number;
  27842. /**
  27843. * Creates a new TonemapPostProcess
  27844. * @param name defines the name of the postprocess
  27845. * @param _operator defines the operator to use
  27846. * @param exposureAdjustment defines the required exposure adjustement
  27847. * @param camera defines the camera to use (can be null)
  27848. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  27849. * @param engine defines the hosting engine (can be ignore if camera is set)
  27850. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27851. */
  27852. constructor(name: string, _operator: TonemappingOperator,
  27853. /** Defines the required exposure adjustement */
  27854. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  27855. }
  27856. }
  27857. declare module BABYLON {
  27858. class VolumetricLightScatteringPostProcess extends PostProcess {
  27859. private _volumetricLightScatteringPass;
  27860. private _volumetricLightScatteringRTT;
  27861. private _viewPort;
  27862. private _screenCoordinates;
  27863. private _cachedDefines;
  27864. /**
  27865. * If not undefined, the mesh position is computed from the attached node position
  27866. */
  27867. attachedNode: {
  27868. position: Vector3;
  27869. };
  27870. /**
  27871. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  27872. */
  27873. customMeshPosition: Vector3;
  27874. /**
  27875. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  27876. */
  27877. useCustomMeshPosition: boolean;
  27878. /**
  27879. * If the post-process should inverse the light scattering direction
  27880. */
  27881. invert: boolean;
  27882. /**
  27883. * The internal mesh used by the post-process
  27884. */
  27885. mesh: Mesh;
  27886. useDiffuseColor: boolean;
  27887. /**
  27888. * Array containing the excluded meshes not rendered in the internal pass
  27889. */
  27890. excludedMeshes: AbstractMesh[];
  27891. /**
  27892. * Controls the overall intensity of the post-process
  27893. */
  27894. exposure: number;
  27895. /**
  27896. * Dissipates each sample's contribution in range [0, 1]
  27897. */
  27898. decay: number;
  27899. /**
  27900. * Controls the overall intensity of each sample
  27901. */
  27902. weight: number;
  27903. /**
  27904. * Controls the density of each sample
  27905. */
  27906. density: number;
  27907. /**
  27908. * @constructor
  27909. * @param {string} name - The post-process name
  27910. * @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)
  27911. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  27912. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  27913. * @param {number} samples - The post-process quality, default 100
  27914. * @param {number} samplingMode - The post-process filtering mode
  27915. * @param {BABYLON.Engine} engine - The babylon engine
  27916. * @param {boolean} reusable - If the post-process is reusable
  27917. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  27918. */
  27919. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  27920. getClassName(): string;
  27921. private _isReady;
  27922. /**
  27923. * Sets the new light position for light scattering effect
  27924. * @param {BABYLON.Vector3} The new custom light position
  27925. */
  27926. setCustomMeshPosition(position: Vector3): void;
  27927. /**
  27928. * Returns the light position for light scattering effect
  27929. * @return {BABYLON.Vector3} The custom light position
  27930. */
  27931. getCustomMeshPosition(): Vector3;
  27932. /**
  27933. * Disposes the internal assets and detaches the post-process from the camera
  27934. */
  27935. dispose(camera: Camera): void;
  27936. /**
  27937. * Returns the render target texture used by the post-process
  27938. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  27939. */
  27940. getPass(): RenderTargetTexture;
  27941. private _meshExcluded;
  27942. private _createPass;
  27943. private _updateMeshScreenCoordinates;
  27944. /**
  27945. * Creates a default mesh for the Volumeric Light Scattering post-process
  27946. * @param {string} The mesh name
  27947. * @param {BABYLON.Scene} The scene where to create the mesh
  27948. * @return {BABYLON.Mesh} the default mesh
  27949. */
  27950. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  27951. }
  27952. }
  27953. declare module BABYLON {
  27954. class VRDistortionCorrectionPostProcess extends PostProcess {
  27955. private _isRightEye;
  27956. private _distortionFactors;
  27957. private _postProcessScaleFactor;
  27958. private _lensCenterOffset;
  27959. private _scaleIn;
  27960. private _scaleFactor;
  27961. private _lensCenter;
  27962. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  27963. }
  27964. }
  27965. declare module BABYLON {
  27966. /**
  27967. * Class used to generate realtime reflection / refraction cube textures
  27968. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  27969. */
  27970. class ReflectionProbe {
  27971. /** defines the name of the probe */
  27972. name: string;
  27973. private _scene;
  27974. private _renderTargetTexture;
  27975. private _projectionMatrix;
  27976. private _viewMatrix;
  27977. private _target;
  27978. private _add;
  27979. private _attachedMesh;
  27980. private _invertYAxis;
  27981. /** Gets or sets probe position (center of the cube map) */
  27982. position: Vector3;
  27983. /**
  27984. * Creates a new reflection probe
  27985. * @param name defines the name of the probe
  27986. * @param size defines the texture resolution (for each face)
  27987. * @param scene defines the hosting scene
  27988. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  27989. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  27990. */
  27991. constructor(
  27992. /** defines the name of the probe */
  27993. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  27994. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  27995. samples: number;
  27996. /** Gets or sets the refresh rate to use (on every frame by default) */
  27997. refreshRate: number;
  27998. /**
  27999. * Gets the hosting scene
  28000. * @returns a Scene
  28001. */
  28002. getScene(): Scene;
  28003. /** Gets the internal CubeTexture used to render to */
  28004. readonly cubeTexture: RenderTargetTexture;
  28005. /** Gets the list of meshes to render */
  28006. readonly renderList: Nullable<AbstractMesh[]>;
  28007. /**
  28008. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  28009. * @param mesh defines the mesh to attach to
  28010. */
  28011. attachToMesh(mesh: AbstractMesh): void;
  28012. /**
  28013. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  28014. * @param renderingGroupId The rendering group id corresponding to its index
  28015. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28016. */
  28017. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28018. /**
  28019. * Clean all associated resources
  28020. */
  28021. dispose(): void;
  28022. }
  28023. }
  28024. declare module BABYLON {
  28025. interface Scene {
  28026. /** @hidden (Backing field) */
  28027. _boundingBoxRenderer: BoundingBoxRenderer;
  28028. /** @hidden (Backing field) */
  28029. _forceShowBoundingBoxes: boolean;
  28030. /**
  28031. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  28032. */
  28033. forceShowBoundingBoxes: boolean;
  28034. /**
  28035. * Gets the bounding box renderer associated with the scene
  28036. * @returns a BoundingBoxRenderer
  28037. */
  28038. getBoundingBoxRenderer(): BoundingBoxRenderer;
  28039. }
  28040. interface AbstractMesh {
  28041. /** @hidden (Backing field) */
  28042. _showBoundingBox: boolean;
  28043. /**
  28044. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  28045. */
  28046. showBoundingBox: boolean;
  28047. }
  28048. class BoundingBoxRenderer implements ISceneComponent {
  28049. /**
  28050. * The component name helpfull to identify the component in the list of scene components.
  28051. */
  28052. readonly name: string;
  28053. /**
  28054. * The scene the component belongs to.
  28055. */
  28056. scene: Scene;
  28057. frontColor: Color3;
  28058. backColor: Color3;
  28059. showBackLines: boolean;
  28060. renderList: SmartArray<BoundingBox>;
  28061. private _colorShader;
  28062. private _vertexBuffers;
  28063. private _indexBuffer;
  28064. constructor(scene: Scene);
  28065. /**
  28066. * Registers the component in a given scene
  28067. */
  28068. register(): void;
  28069. private _evaluateSubMesh;
  28070. private _activeMesh;
  28071. private _prepareRessources;
  28072. private _createIndexBuffer;
  28073. /**
  28074. * Rebuilds the elements related to this component in case of
  28075. * context lost for instance.
  28076. */
  28077. rebuild(): void;
  28078. reset(): void;
  28079. render(): void;
  28080. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  28081. dispose(): void;
  28082. }
  28083. }
  28084. declare module BABYLON {
  28085. /**
  28086. * This represents a depth renderer in Babylon.
  28087. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  28088. */
  28089. class DepthRenderer {
  28090. private _scene;
  28091. private _depthMap;
  28092. private _effect;
  28093. private _cachedDefines;
  28094. private _camera;
  28095. /**
  28096. * Instantiates a depth renderer
  28097. * @param scene The scene the renderer belongs to
  28098. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  28099. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  28100. */
  28101. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  28102. /**
  28103. * Creates the depth rendering effect and checks if the effect is ready.
  28104. * @param subMesh The submesh to be used to render the depth map of
  28105. * @param useInstances If multiple world instances should be used
  28106. * @returns if the depth renderer is ready to render the depth map
  28107. */
  28108. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28109. /**
  28110. * Gets the texture which the depth map will be written to.
  28111. * @returns The depth map texture
  28112. */
  28113. getDepthMap(): RenderTargetTexture;
  28114. /**
  28115. * Disposes of the depth renderer.
  28116. */
  28117. dispose(): void;
  28118. }
  28119. }
  28120. declare module BABYLON {
  28121. class EdgesRenderer {
  28122. edgesWidthScalerForOrthographic: number;
  28123. edgesWidthScalerForPerspective: number;
  28124. private _source;
  28125. private _linesPositions;
  28126. private _linesNormals;
  28127. private _linesIndices;
  28128. private _epsilon;
  28129. private _indicesCount;
  28130. private _lineShader;
  28131. private _ib;
  28132. private _buffers;
  28133. private _checkVerticesInsteadOfIndices;
  28134. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28135. isEnabled: boolean;
  28136. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28137. private _prepareRessources;
  28138. _rebuild(): void;
  28139. dispose(): void;
  28140. private _processEdgeForAdjacencies;
  28141. private _processEdgeForAdjacenciesWithVertices;
  28142. private _checkEdge;
  28143. _generateEdgesLines(): void;
  28144. render(): void;
  28145. }
  28146. }
  28147. declare module BABYLON {
  28148. /**
  28149. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28150. */
  28151. class GeometryBufferRenderer {
  28152. private _scene;
  28153. private _multiRenderTarget;
  28154. private _ratio;
  28155. private _enablePosition;
  28156. protected _effect: Effect;
  28157. protected _cachedDefines: string;
  28158. /**
  28159. * Set the render list (meshes to be rendered) used in the G buffer.
  28160. */
  28161. renderList: Mesh[];
  28162. /**
  28163. * Gets wether or not G buffer are supported by the running hardware.
  28164. * This requires draw buffer supports
  28165. */
  28166. readonly isSupported: boolean;
  28167. /**
  28168. * Gets wether or not position are enabled for the G buffer.
  28169. */
  28170. /**
  28171. * Sets wether or not position are enabled for the G buffer.
  28172. */
  28173. enablePosition: boolean;
  28174. /**
  28175. * Gets the scene associated with the buffer.
  28176. */
  28177. readonly scene: Scene;
  28178. /**
  28179. * Gets the ratio used by the buffer during its creation.
  28180. * How big is the buffer related to the main canvas.
  28181. */
  28182. readonly ratio: number;
  28183. /**
  28184. * Creates a new G Buffer for the scene
  28185. * @param scene The scene the buffer belongs to
  28186. * @param ratio How big is the buffer related to the main canvas.
  28187. */
  28188. constructor(scene: Scene, ratio?: number);
  28189. /**
  28190. * Checks wether everything is ready to render a submesh to the G buffer.
  28191. * @param subMesh the submesh to check readiness for
  28192. * @param useInstances is the mesh drawn using instance or not
  28193. * @returns true if ready otherwise false
  28194. */
  28195. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28196. /**
  28197. * Gets the current underlying G Buffer.
  28198. * @returns the buffer
  28199. */
  28200. getGBuffer(): MultiRenderTarget;
  28201. /**
  28202. * Gets the number of samples used to render the buffer (anti aliasing).
  28203. */
  28204. /**
  28205. * Sets the number of samples used to render the buffer (anti aliasing).
  28206. */
  28207. samples: number;
  28208. /**
  28209. * Disposes the renderer and frees up associated resources.
  28210. */
  28211. dispose(): void;
  28212. protected _createRenderTargets(): void;
  28213. }
  28214. }
  28215. declare module BABYLON {
  28216. class OutlineRenderer {
  28217. private _scene;
  28218. private _effect;
  28219. private _cachedDefines;
  28220. zOffset: number;
  28221. constructor(scene: Scene);
  28222. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  28223. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28224. }
  28225. }
  28226. declare module BABYLON {
  28227. class RenderingGroup {
  28228. index: number;
  28229. private _scene;
  28230. private _opaqueSubMeshes;
  28231. private _transparentSubMeshes;
  28232. private _alphaTestSubMeshes;
  28233. private _depthOnlySubMeshes;
  28234. private _particleSystems;
  28235. private _spriteManagers;
  28236. private _opaqueSortCompareFn;
  28237. private _alphaTestSortCompareFn;
  28238. private _transparentSortCompareFn;
  28239. private _renderOpaque;
  28240. private _renderAlphaTest;
  28241. private _renderTransparent;
  28242. private _edgesRenderers;
  28243. onBeforeTransparentRendering: () => void;
  28244. /**
  28245. * Set the opaque sort comparison function.
  28246. * If null the sub meshes will be render in the order they were created
  28247. */
  28248. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28249. /**
  28250. * Set the alpha test sort comparison function.
  28251. * If null the sub meshes will be render in the order they were created
  28252. */
  28253. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28254. /**
  28255. * Set the transparent sort comparison function.
  28256. * If null the sub meshes will be render in the order they were created
  28257. */
  28258. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28259. /**
  28260. * Creates a new rendering group.
  28261. * @param index The rendering group index
  28262. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28263. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28264. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28265. */
  28266. 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>);
  28267. /**
  28268. * Render all the sub meshes contained in the group.
  28269. * @param customRenderFunction Used to override the default render behaviour of the group.
  28270. * @returns true if rendered some submeshes.
  28271. */
  28272. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28273. /**
  28274. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28275. * @param subMeshes The submeshes to render
  28276. */
  28277. private renderOpaqueSorted;
  28278. /**
  28279. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28280. * @param subMeshes The submeshes to render
  28281. */
  28282. private renderAlphaTestSorted;
  28283. /**
  28284. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28285. * @param subMeshes The submeshes to render
  28286. */
  28287. private renderTransparentSorted;
  28288. /**
  28289. * Renders the submeshes in a specified order.
  28290. * @param subMeshes The submeshes to sort before render
  28291. * @param sortCompareFn The comparison function use to sort
  28292. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28293. * @param transparent Specifies to activate blending if true
  28294. */
  28295. private static renderSorted;
  28296. /**
  28297. * Renders the submeshes in the order they were dispatched (no sort applied).
  28298. * @param subMeshes The submeshes to render
  28299. */
  28300. private static renderUnsorted;
  28301. /**
  28302. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28303. * are rendered back to front if in the same alpha index.
  28304. *
  28305. * @param a The first submesh
  28306. * @param b The second submesh
  28307. * @returns The result of the comparison
  28308. */
  28309. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28310. /**
  28311. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28312. * are rendered back to front.
  28313. *
  28314. * @param a The first submesh
  28315. * @param b The second submesh
  28316. * @returns The result of the comparison
  28317. */
  28318. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28319. /**
  28320. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28321. * are rendered front to back (prevent overdraw).
  28322. *
  28323. * @param a The first submesh
  28324. * @param b The second submesh
  28325. * @returns The result of the comparison
  28326. */
  28327. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28328. /**
  28329. * Resets the different lists of submeshes to prepare a new frame.
  28330. */
  28331. prepare(): void;
  28332. dispose(): void;
  28333. /**
  28334. * Inserts the submesh in its correct queue depending on its material.
  28335. * @param subMesh The submesh to dispatch
  28336. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28337. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28338. */
  28339. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28340. dispatchSprites(spriteManager: SpriteManager): void;
  28341. dispatchParticles(particleSystem: IParticleSystem): void;
  28342. private _renderParticles;
  28343. private _renderSprites;
  28344. }
  28345. }
  28346. declare module BABYLON {
  28347. /**
  28348. * Interface describing the different options available in the rendering manager
  28349. * regarding Auto Clear between groups.
  28350. */
  28351. interface IRenderingManagerAutoClearSetup {
  28352. /**
  28353. * Defines whether or not autoclear is enable.
  28354. */
  28355. autoClear: boolean;
  28356. /**
  28357. * Defines whether or not to autoclear the depth buffer.
  28358. */
  28359. depth: boolean;
  28360. /**
  28361. * Defines whether or not to autoclear the stencil buffer.
  28362. */
  28363. stencil: boolean;
  28364. }
  28365. class RenderingManager {
  28366. /**
  28367. * The max id used for rendering groups (not included)
  28368. */
  28369. static MAX_RENDERINGGROUPS: number;
  28370. /**
  28371. * The min id used for rendering groups (included)
  28372. */
  28373. static MIN_RENDERINGGROUPS: number;
  28374. /**
  28375. * Used to globally prevent autoclearing scenes.
  28376. */
  28377. static AUTOCLEAR: boolean;
  28378. /**
  28379. * Hidden
  28380. */
  28381. _useSceneAutoClearSetup: boolean;
  28382. private _scene;
  28383. private _renderingGroups;
  28384. private _depthStencilBufferAlreadyCleaned;
  28385. private _autoClearDepthStencil;
  28386. private _customOpaqueSortCompareFn;
  28387. private _customAlphaTestSortCompareFn;
  28388. private _customTransparentSortCompareFn;
  28389. private _renderingGroupInfo;
  28390. constructor(scene: Scene);
  28391. private _clearDepthStencilBuffer;
  28392. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28393. reset(): void;
  28394. dispose(): void;
  28395. /**
  28396. * Clear the info related to rendering groups preventing retention points during dispose.
  28397. */
  28398. freeRenderingGroups(): void;
  28399. private _prepareRenderingGroup;
  28400. dispatchSprites(spriteManager: SpriteManager): void;
  28401. dispatchParticles(particleSystem: IParticleSystem): void;
  28402. /**
  28403. * @param subMesh The submesh to dispatch
  28404. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28405. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28406. */
  28407. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28408. /**
  28409. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28410. * This allowed control for front to back rendering or reversly depending of the special needs.
  28411. *
  28412. * @param renderingGroupId The rendering group id corresponding to its index
  28413. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28414. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28415. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28416. */
  28417. 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;
  28418. /**
  28419. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28420. *
  28421. * @param renderingGroupId The rendering group id corresponding to its index
  28422. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28423. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28424. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28425. */
  28426. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28427. /**
  28428. * Gets the current auto clear configuration for one rendering group of the rendering
  28429. * manager.
  28430. * @param index the rendering group index to get the information for
  28431. * @returns The auto clear setup for the requested rendering group
  28432. */
  28433. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28434. }
  28435. }
  28436. declare module BABYLON {
  28437. /**
  28438. * Renders a layer on top of an existing scene
  28439. */
  28440. class UtilityLayerRenderer implements IDisposable {
  28441. /** the original scene that will be rendered on top of */
  28442. originalScene: Scene;
  28443. private _pointerCaptures;
  28444. private _lastPointerEvents;
  28445. private static _DefaultUtilityLayer;
  28446. private static _DefaultKeepDepthUtilityLayer;
  28447. /**
  28448. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  28449. */
  28450. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  28451. /**
  28452. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  28453. */
  28454. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  28455. /**
  28456. * The scene that is rendered on top of the original scene
  28457. */
  28458. utilityLayerScene: Scene;
  28459. /**
  28460. * If the utility layer should automatically be rendered on top of existing scene
  28461. */
  28462. shouldRender: boolean;
  28463. /**
  28464. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  28465. */
  28466. onlyCheckPointerDownEvents: boolean;
  28467. /**
  28468. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  28469. */
  28470. processAllEvents: boolean;
  28471. /**
  28472. * Observable raised when the pointer move from the utility layer scene to the main scene
  28473. */
  28474. onPointerOutObservable: Observable<number>;
  28475. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  28476. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  28477. private _afterRenderObserver;
  28478. private _sceneDisposeObserver;
  28479. private _originalPointerObserver;
  28480. /**
  28481. * Instantiates a UtilityLayerRenderer
  28482. * @param originalScene the original scene that will be rendered on top of
  28483. */
  28484. constructor(
  28485. /** the original scene that will be rendered on top of */
  28486. originalScene: Scene);
  28487. private _notifyObservers;
  28488. /**
  28489. * Renders the utility layers scene on top of the original scene
  28490. */
  28491. render(): void;
  28492. /**
  28493. * Disposes of the renderer
  28494. */
  28495. dispose(): void;
  28496. private _updateCamera;
  28497. }
  28498. }
  28499. declare module BABYLON {
  28500. class Sprite {
  28501. name: string;
  28502. position: Vector3;
  28503. color: Color4;
  28504. width: number;
  28505. height: number;
  28506. angle: number;
  28507. cellIndex: number;
  28508. invertU: number;
  28509. invertV: number;
  28510. disposeWhenFinishedAnimating: boolean;
  28511. animations: Animation[];
  28512. isPickable: boolean;
  28513. actionManager: ActionManager;
  28514. private _animationStarted;
  28515. private _loopAnimation;
  28516. private _fromIndex;
  28517. private _toIndex;
  28518. private _delay;
  28519. private _direction;
  28520. private _manager;
  28521. private _time;
  28522. private _onAnimationEnd;
  28523. /**
  28524. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  28525. */
  28526. isVisible: boolean;
  28527. size: number;
  28528. constructor(name: string, manager: SpriteManager);
  28529. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  28530. stopAnimation(): void;
  28531. _animate(deltaTime: number): void;
  28532. dispose(): void;
  28533. }
  28534. }
  28535. declare module BABYLON {
  28536. class SpriteManager {
  28537. name: string;
  28538. sprites: Sprite[];
  28539. renderingGroupId: number;
  28540. layerMask: number;
  28541. fogEnabled: boolean;
  28542. isPickable: boolean;
  28543. cellWidth: number;
  28544. cellHeight: number;
  28545. /**
  28546. * An event triggered when the manager is disposed.
  28547. */
  28548. onDisposeObservable: Observable<SpriteManager>;
  28549. private _onDisposeObserver;
  28550. onDispose: () => void;
  28551. private _capacity;
  28552. private _spriteTexture;
  28553. private _epsilon;
  28554. private _scene;
  28555. private _vertexData;
  28556. private _buffer;
  28557. private _vertexBuffers;
  28558. private _indexBuffer;
  28559. private _effectBase;
  28560. private _effectFog;
  28561. texture: Texture;
  28562. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  28563. private _appendSpriteVertex;
  28564. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  28565. render(): void;
  28566. dispose(): void;
  28567. }
  28568. }
  28569. declare module BABYLON {
  28570. /**
  28571. * @hidden
  28572. **/
  28573. class _AlphaState {
  28574. private _isAlphaBlendDirty;
  28575. private _isBlendFunctionParametersDirty;
  28576. private _isBlendEquationParametersDirty;
  28577. private _isBlendConstantsDirty;
  28578. private _alphaBlend;
  28579. private _blendFunctionParameters;
  28580. private _blendEquationParameters;
  28581. private _blendConstants;
  28582. /**
  28583. * Initializes the state.
  28584. */
  28585. constructor();
  28586. readonly isDirty: boolean;
  28587. alphaBlend: boolean;
  28588. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28589. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28590. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28591. reset(): void;
  28592. apply(gl: WebGLRenderingContext): void;
  28593. }
  28594. }
  28595. declare module BABYLON {
  28596. /**
  28597. * @hidden
  28598. **/
  28599. class _DepthCullingState {
  28600. private _isDepthTestDirty;
  28601. private _isDepthMaskDirty;
  28602. private _isDepthFuncDirty;
  28603. private _isCullFaceDirty;
  28604. private _isCullDirty;
  28605. private _isZOffsetDirty;
  28606. private _isFrontFaceDirty;
  28607. private _depthTest;
  28608. private _depthMask;
  28609. private _depthFunc;
  28610. private _cull;
  28611. private _cullFace;
  28612. private _zOffset;
  28613. private _frontFace;
  28614. /**
  28615. * Initializes the state.
  28616. */
  28617. constructor();
  28618. readonly isDirty: boolean;
  28619. zOffset: number;
  28620. cullFace: Nullable<number>;
  28621. cull: Nullable<boolean>;
  28622. depthFunc: Nullable<number>;
  28623. depthMask: boolean;
  28624. depthTest: boolean;
  28625. frontFace: Nullable<number>;
  28626. reset(): void;
  28627. apply(gl: WebGLRenderingContext): void;
  28628. }
  28629. }
  28630. declare module BABYLON {
  28631. /**
  28632. * @hidden
  28633. **/
  28634. class _StencilState {
  28635. private _isStencilTestDirty;
  28636. private _isStencilMaskDirty;
  28637. private _isStencilFuncDirty;
  28638. private _isStencilOpDirty;
  28639. private _stencilTest;
  28640. private _stencilMask;
  28641. private _stencilFunc;
  28642. private _stencilFuncRef;
  28643. private _stencilFuncMask;
  28644. private _stencilOpStencilFail;
  28645. private _stencilOpDepthFail;
  28646. private _stencilOpStencilDepthPass;
  28647. readonly isDirty: boolean;
  28648. stencilFunc: number;
  28649. stencilFuncRef: number;
  28650. stencilFuncMask: number;
  28651. stencilOpStencilFail: number;
  28652. stencilOpDepthFail: number;
  28653. stencilOpStencilDepthPass: number;
  28654. stencilMask: number;
  28655. stencilTest: boolean;
  28656. constructor();
  28657. reset(): void;
  28658. apply(gl: WebGLRenderingContext): void;
  28659. }
  28660. }
  28661. declare module BABYLON {
  28662. /**
  28663. * Class used to evalaute queries containing `and` and `or` operators
  28664. */
  28665. class AndOrNotEvaluator {
  28666. /**
  28667. * Evaluate a query
  28668. * @param query defines the query to evaluate
  28669. * @param evaluateCallback defines the callback used to filter result
  28670. * @returns true if the query matches
  28671. */
  28672. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  28673. private static _HandleParenthesisContent;
  28674. private static _SimplifyNegation;
  28675. }
  28676. }
  28677. declare module BABYLON {
  28678. /**
  28679. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  28680. */
  28681. enum AssetTaskState {
  28682. /**
  28683. * Initialization
  28684. */
  28685. INIT = 0,
  28686. /**
  28687. * Running
  28688. */
  28689. RUNNING = 1,
  28690. /**
  28691. * Done
  28692. */
  28693. DONE = 2,
  28694. /**
  28695. * Error
  28696. */
  28697. ERROR = 3
  28698. }
  28699. /**
  28700. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  28701. */
  28702. abstract class AbstractAssetTask {
  28703. /**
  28704. * Task name
  28705. */ name: string;
  28706. /**
  28707. * Callback called when the task is successful
  28708. */
  28709. onSuccess: (task: any) => void;
  28710. /**
  28711. * Callback called when the task is not successful
  28712. */
  28713. onError: (task: any, message?: string, exception?: any) => void;
  28714. /**
  28715. * Creates a new {BABYLON.AssetsManager}
  28716. * @param name defines the name of the task
  28717. */
  28718. constructor(
  28719. /**
  28720. * Task name
  28721. */ name: string);
  28722. private _isCompleted;
  28723. private _taskState;
  28724. private _errorObject;
  28725. /**
  28726. * Get if the task is completed
  28727. */
  28728. readonly isCompleted: boolean;
  28729. /**
  28730. * Gets the current state of the task
  28731. */
  28732. readonly taskState: AssetTaskState;
  28733. /**
  28734. * Gets the current error object (if task is in error)
  28735. */
  28736. readonly errorObject: {
  28737. message?: string;
  28738. exception?: any;
  28739. };
  28740. /**
  28741. * Internal only
  28742. * @hidden
  28743. */
  28744. _setErrorObject(message?: string, exception?: any): void;
  28745. /**
  28746. * Execute the current task
  28747. * @param scene defines the scene where you want your assets to be loaded
  28748. * @param onSuccess is a callback called when the task is successfully executed
  28749. * @param onError is a callback called if an error occurs
  28750. */
  28751. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28752. /**
  28753. * Execute the current task
  28754. * @param scene defines the scene where you want your assets to be loaded
  28755. * @param onSuccess is a callback called when the task is successfully executed
  28756. * @param onError is a callback called if an error occurs
  28757. */
  28758. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28759. /**
  28760. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  28761. * This can be used with failed tasks that have the reason for failure fixed.
  28762. */
  28763. reset(): void;
  28764. private onErrorCallback;
  28765. private onDoneCallback;
  28766. }
  28767. /**
  28768. * Define the interface used by progress events raised during assets loading
  28769. */
  28770. interface IAssetsProgressEvent {
  28771. /**
  28772. * Defines the number of remaining tasks to process
  28773. */
  28774. remainingCount: number;
  28775. /**
  28776. * Defines the total number of tasks
  28777. */
  28778. totalCount: number;
  28779. /**
  28780. * Defines the task that was just processed
  28781. */
  28782. task: AbstractAssetTask;
  28783. }
  28784. /**
  28785. * Class used to share progress information about assets loading
  28786. */
  28787. class AssetsProgressEvent implements IAssetsProgressEvent {
  28788. /**
  28789. * Defines the number of remaining tasks to process
  28790. */
  28791. remainingCount: number;
  28792. /**
  28793. * Defines the total number of tasks
  28794. */
  28795. totalCount: number;
  28796. /**
  28797. * Defines the task that was just processed
  28798. */
  28799. task: AbstractAssetTask;
  28800. /**
  28801. * Creates a {BABYLON.AssetsProgressEvent}
  28802. * @param remainingCount defines the number of remaining tasks to process
  28803. * @param totalCount defines the total number of tasks
  28804. * @param task defines the task that was just processed
  28805. */
  28806. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  28807. }
  28808. /**
  28809. * Define a task used by {BABYLON.AssetsManager} to load meshes
  28810. */
  28811. class MeshAssetTask extends AbstractAssetTask {
  28812. /**
  28813. * Defines the name of the task
  28814. */
  28815. name: string;
  28816. /**
  28817. * Defines the list of mesh's names you want to load
  28818. */
  28819. meshesNames: any;
  28820. /**
  28821. * Defines the root url to use as a base to load your meshes and associated resources
  28822. */
  28823. rootUrl: string;
  28824. /**
  28825. * Defines the filename of the scene to load from
  28826. */
  28827. sceneFilename: string;
  28828. /**
  28829. * Gets the list of loaded meshes
  28830. */
  28831. loadedMeshes: Array<AbstractMesh>;
  28832. /**
  28833. * Gets the list of loaded particle systems
  28834. */
  28835. loadedParticleSystems: Array<IParticleSystem>;
  28836. /**
  28837. * Gets the list of loaded skeletons
  28838. */
  28839. loadedSkeletons: Array<Skeleton>;
  28840. /**
  28841. * Callback called when the task is successful
  28842. */
  28843. onSuccess: (task: MeshAssetTask) => void;
  28844. /**
  28845. * Callback called when the task is successful
  28846. */
  28847. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  28848. /**
  28849. * Creates a new {BABYLON.MeshAssetTask}
  28850. * @param name defines the name of the task
  28851. * @param meshesNames defines the list of mesh's names you want to load
  28852. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  28853. * @param sceneFilename defines the filename of the scene to load from
  28854. */
  28855. constructor(
  28856. /**
  28857. * Defines the name of the task
  28858. */
  28859. name: string,
  28860. /**
  28861. * Defines the list of mesh's names you want to load
  28862. */
  28863. meshesNames: any,
  28864. /**
  28865. * Defines the root url to use as a base to load your meshes and associated resources
  28866. */
  28867. rootUrl: string,
  28868. /**
  28869. * Defines the filename of the scene to load from
  28870. */
  28871. sceneFilename: string);
  28872. /**
  28873. * Execute the current task
  28874. * @param scene defines the scene where you want your assets to be loaded
  28875. * @param onSuccess is a callback called when the task is successfully executed
  28876. * @param onError is a callback called if an error occurs
  28877. */
  28878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28879. }
  28880. /**
  28881. * Define a task used by {BABYLON.AssetsManager} to load text content
  28882. */
  28883. class TextFileAssetTask extends AbstractAssetTask {
  28884. /**
  28885. * Defines the name of the task
  28886. */
  28887. name: string;
  28888. /**
  28889. * Defines the location of the file to load
  28890. */
  28891. url: string;
  28892. /**
  28893. * Gets the loaded text string
  28894. */
  28895. text: string;
  28896. /**
  28897. * Callback called when the task is successful
  28898. */
  28899. onSuccess: (task: TextFileAssetTask) => void;
  28900. /**
  28901. * Callback called when the task is successful
  28902. */
  28903. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  28904. /**
  28905. * Creates a new TextFileAssetTask object
  28906. * @param name defines the name of the task
  28907. * @param url defines the location of the file to load
  28908. */
  28909. constructor(
  28910. /**
  28911. * Defines the name of the task
  28912. */
  28913. name: string,
  28914. /**
  28915. * Defines the location of the file to load
  28916. */
  28917. url: string);
  28918. /**
  28919. * Execute the current task
  28920. * @param scene defines the scene where you want your assets to be loaded
  28921. * @param onSuccess is a callback called when the task is successfully executed
  28922. * @param onError is a callback called if an error occurs
  28923. */
  28924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28925. }
  28926. /**
  28927. * Define a task used by {BABYLON.AssetsManager} to load binary data
  28928. */
  28929. class BinaryFileAssetTask extends AbstractAssetTask {
  28930. /**
  28931. * Defines the name of the task
  28932. */
  28933. name: string;
  28934. /**
  28935. * Defines the location of the file to load
  28936. */
  28937. url: string;
  28938. /**
  28939. * Gets the lodaded data (as an array buffer)
  28940. */
  28941. data: ArrayBuffer;
  28942. /**
  28943. * Callback called when the task is successful
  28944. */
  28945. onSuccess: (task: BinaryFileAssetTask) => void;
  28946. /**
  28947. * Callback called when the task is successful
  28948. */
  28949. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  28950. /**
  28951. * Creates a new BinaryFileAssetTask object
  28952. * @param name defines the name of the new task
  28953. * @param url defines the location of the file to load
  28954. */
  28955. constructor(
  28956. /**
  28957. * Defines the name of the task
  28958. */
  28959. name: string,
  28960. /**
  28961. * Defines the location of the file to load
  28962. */
  28963. url: string);
  28964. /**
  28965. * Execute the current task
  28966. * @param scene defines the scene where you want your assets to be loaded
  28967. * @param onSuccess is a callback called when the task is successfully executed
  28968. * @param onError is a callback called if an error occurs
  28969. */
  28970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28971. }
  28972. /**
  28973. * Define a task used by {BABYLON.AssetsManager} to load images
  28974. */
  28975. class ImageAssetTask extends AbstractAssetTask {
  28976. /**
  28977. * Defines the name of the task
  28978. */
  28979. name: string;
  28980. /**
  28981. * Defines the location of the image to load
  28982. */
  28983. url: string;
  28984. /**
  28985. * Gets the loaded images
  28986. */
  28987. image: HTMLImageElement;
  28988. /**
  28989. * Callback called when the task is successful
  28990. */
  28991. onSuccess: (task: ImageAssetTask) => void;
  28992. /**
  28993. * Callback called when the task is successful
  28994. */
  28995. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  28996. /**
  28997. * Creates a new ImageAssetTask
  28998. * @param name defines the name of the task
  28999. * @param url defines the location of the image to load
  29000. */
  29001. constructor(
  29002. /**
  29003. * Defines the name of the task
  29004. */
  29005. name: string,
  29006. /**
  29007. * Defines the location of the image to load
  29008. */
  29009. url: string);
  29010. /**
  29011. * Execute the current task
  29012. * @param scene defines the scene where you want your assets to be loaded
  29013. * @param onSuccess is a callback called when the task is successfully executed
  29014. * @param onError is a callback called if an error occurs
  29015. */
  29016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29017. }
  29018. /**
  29019. * Defines the interface used by texture loading tasks
  29020. */
  29021. interface ITextureAssetTask<TEX extends BaseTexture> {
  29022. /**
  29023. * Gets the loaded texture
  29024. */
  29025. texture: TEX;
  29026. }
  29027. /**
  29028. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  29029. */
  29030. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  29031. /**
  29032. * Defines the name of the task
  29033. */
  29034. name: string;
  29035. /**
  29036. * Defines the location of the file to load
  29037. */
  29038. url: string;
  29039. /**
  29040. * Defines if mipmap should not be generated (default is false)
  29041. */
  29042. noMipmap?: boolean | undefined;
  29043. /**
  29044. * Defines if texture must be inverted on Y axis (default is false)
  29045. */
  29046. invertY?: boolean | undefined;
  29047. /**
  29048. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29049. */
  29050. samplingMode: number;
  29051. /**
  29052. * Gets the loaded texture
  29053. */
  29054. texture: Texture;
  29055. /**
  29056. * Callback called when the task is successful
  29057. */
  29058. onSuccess: (task: TextureAssetTask) => void;
  29059. /**
  29060. * Callback called when the task is successful
  29061. */
  29062. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  29063. /**
  29064. * Creates a new TextureAssetTask object
  29065. * @param name defines the name of the task
  29066. * @param url defines the location of the file to load
  29067. * @param noMipmap defines if mipmap should not be generated (default is false)
  29068. * @param invertY defines if texture must be inverted on Y axis (default is false)
  29069. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29070. */
  29071. constructor(
  29072. /**
  29073. * Defines the name of the task
  29074. */
  29075. name: string,
  29076. /**
  29077. * Defines the location of the file to load
  29078. */
  29079. url: string,
  29080. /**
  29081. * Defines if mipmap should not be generated (default is false)
  29082. */
  29083. noMipmap?: boolean | undefined,
  29084. /**
  29085. * Defines if texture must be inverted on Y axis (default is false)
  29086. */
  29087. invertY?: boolean | undefined,
  29088. /**
  29089. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29090. */
  29091. samplingMode?: number);
  29092. /**
  29093. * Execute the current task
  29094. * @param scene defines the scene where you want your assets to be loaded
  29095. * @param onSuccess is a callback called when the task is successfully executed
  29096. * @param onError is a callback called if an error occurs
  29097. */
  29098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29099. }
  29100. /**
  29101. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  29102. */
  29103. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  29104. /**
  29105. * Defines the name of the task
  29106. */
  29107. name: string;
  29108. /**
  29109. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29110. */
  29111. url: string;
  29112. /**
  29113. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29114. */
  29115. extensions?: string[] | undefined;
  29116. /**
  29117. * Defines if mipmaps should not be generated (default is false)
  29118. */
  29119. noMipmap?: boolean | undefined;
  29120. /**
  29121. * Defines the explicit list of files (undefined by default)
  29122. */
  29123. files?: string[] | undefined;
  29124. /**
  29125. * Gets the loaded texture
  29126. */
  29127. texture: CubeTexture;
  29128. /**
  29129. * Callback called when the task is successful
  29130. */
  29131. onSuccess: (task: CubeTextureAssetTask) => void;
  29132. /**
  29133. * Callback called when the task is successful
  29134. */
  29135. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  29136. /**
  29137. * Creates a new CubeTextureAssetTask
  29138. * @param name defines the name of the task
  29139. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29140. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29141. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29142. * @param files defines the explicit list of files (undefined by default)
  29143. */
  29144. constructor(
  29145. /**
  29146. * Defines the name of the task
  29147. */
  29148. name: string,
  29149. /**
  29150. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29151. */
  29152. url: string,
  29153. /**
  29154. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29155. */
  29156. extensions?: string[] | undefined,
  29157. /**
  29158. * Defines if mipmaps should not be generated (default is false)
  29159. */
  29160. noMipmap?: boolean | undefined,
  29161. /**
  29162. * Defines the explicit list of files (undefined by default)
  29163. */
  29164. files?: string[] | undefined);
  29165. /**
  29166. * Execute the current task
  29167. * @param scene defines the scene where you want your assets to be loaded
  29168. * @param onSuccess is a callback called when the task is successfully executed
  29169. * @param onError is a callback called if an error occurs
  29170. */
  29171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29172. }
  29173. /**
  29174. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  29175. */
  29176. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  29177. /**
  29178. * Defines the name of the task
  29179. */
  29180. name: string;
  29181. /**
  29182. * Defines the location of the file to load
  29183. */
  29184. url: string;
  29185. /**
  29186. * Defines the desired size (the more it increases the longer the generation will be)
  29187. */
  29188. size: number;
  29189. /**
  29190. * Defines if mipmaps should not be generated (default is false)
  29191. */
  29192. noMipmap: boolean;
  29193. /**
  29194. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29195. */
  29196. generateHarmonics: boolean;
  29197. /**
  29198. * 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)
  29199. */
  29200. gammaSpace: boolean;
  29201. /**
  29202. * Internal Use Only
  29203. */
  29204. reserved: boolean;
  29205. /**
  29206. * Gets the loaded texture
  29207. */
  29208. texture: HDRCubeTexture;
  29209. /**
  29210. * Callback called when the task is successful
  29211. */
  29212. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  29213. /**
  29214. * Callback called when the task is successful
  29215. */
  29216. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  29217. /**
  29218. * Creates a new HDRCubeTextureAssetTask object
  29219. * @param name defines the name of the task
  29220. * @param url defines the location of the file to load
  29221. * @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.
  29222. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29223. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29224. * @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)
  29225. * @param reserved Internal use only
  29226. */
  29227. constructor(
  29228. /**
  29229. * Defines the name of the task
  29230. */
  29231. name: string,
  29232. /**
  29233. * Defines the location of the file to load
  29234. */
  29235. url: string,
  29236. /**
  29237. * Defines the desired size (the more it increases the longer the generation will be)
  29238. */
  29239. size: number,
  29240. /**
  29241. * Defines if mipmaps should not be generated (default is false)
  29242. */
  29243. noMipmap?: boolean,
  29244. /**
  29245. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29246. */
  29247. generateHarmonics?: boolean,
  29248. /**
  29249. * 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)
  29250. */
  29251. gammaSpace?: boolean,
  29252. /**
  29253. * Internal Use Only
  29254. */
  29255. reserved?: boolean);
  29256. /**
  29257. * Execute the current task
  29258. * @param scene defines the scene where you want your assets to be loaded
  29259. * @param onSuccess is a callback called when the task is successfully executed
  29260. * @param onError is a callback called if an error occurs
  29261. */
  29262. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29263. }
  29264. /**
  29265. * This class can be used to easily import assets into a scene
  29266. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  29267. */
  29268. class AssetsManager {
  29269. private _scene;
  29270. private _isLoading;
  29271. protected _tasks: AbstractAssetTask[];
  29272. protected _waitingTasksCount: number;
  29273. protected _totalTasksCount: number;
  29274. /**
  29275. * Callback called when all tasks are processed
  29276. */
  29277. onFinish: (tasks: AbstractAssetTask[]) => void;
  29278. /**
  29279. * Callback called when a task is successful
  29280. */
  29281. onTaskSuccess: (task: AbstractAssetTask) => void;
  29282. /**
  29283. * Callback called when a task had an error
  29284. */
  29285. onTaskError: (task: AbstractAssetTask) => void;
  29286. /**
  29287. * Callback called when a task is done (whatever the result is)
  29288. */
  29289. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  29290. /**
  29291. * Observable called when all tasks are processed
  29292. */
  29293. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  29294. /**
  29295. * Observable called when a task had an error
  29296. */
  29297. onTaskErrorObservable: Observable<AbstractAssetTask>;
  29298. /**
  29299. * Observable called when a task is successful
  29300. */
  29301. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  29302. /**
  29303. * Observable called when a task is done (whatever the result is)
  29304. */
  29305. onProgressObservable: Observable<IAssetsProgressEvent>;
  29306. /**
  29307. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  29308. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29309. */
  29310. useDefaultLoadingScreen: boolean;
  29311. /**
  29312. * Creates a new AssetsManager
  29313. * @param scene defines the scene to work on
  29314. */
  29315. constructor(scene: Scene);
  29316. /**
  29317. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  29318. * @param taskName defines the name of the new task
  29319. * @param meshesNames defines the name of meshes to load
  29320. * @param rootUrl defines the root url to use to locate files
  29321. * @param sceneFilename defines the filename of the scene file
  29322. * @returns a new {BABYLON.MeshAssetTask} object
  29323. */
  29324. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  29325. /**
  29326. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  29327. * @param taskName defines the name of the new task
  29328. * @param url defines the url of the file to load
  29329. * @returns a new {BABYLON.TextFileAssetTask} object
  29330. */
  29331. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  29332. /**
  29333. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  29334. * @param taskName defines the name of the new task
  29335. * @param url defines the url of the file to load
  29336. * @returns a new {BABYLON.BinaryFileAssetTask} object
  29337. */
  29338. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  29339. /**
  29340. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  29341. * @param taskName defines the name of the new task
  29342. * @param url defines the url of the file to load
  29343. * @returns a new {BABYLON.ImageAssetTask} object
  29344. */
  29345. addImageTask(taskName: string, url: string): ImageAssetTask;
  29346. /**
  29347. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  29348. * @param taskName defines the name of the new task
  29349. * @param url defines the url of the file to load
  29350. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29351. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  29352. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  29353. * @returns a new {BABYLON.TextureAssetTask} object
  29354. */
  29355. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  29356. /**
  29357. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  29358. * @param taskName defines the name of the new task
  29359. * @param url defines the url of the file to load
  29360. * @param extensions defines the extension to use to load the cube map (can be null)
  29361. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29362. * @param files defines the list of files to load (can be null)
  29363. * @returns a new {BABYLON.CubeTextureAssetTask} object
  29364. */
  29365. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  29366. /**
  29367. *
  29368. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  29369. * @param taskName defines the name of the new task
  29370. * @param url defines the url of the file to load
  29371. * @param size defines the size you want for the cubemap (can be null)
  29372. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29373. * @param generateHarmonics defines if you want to automatically generate (true by default)
  29374. * @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)
  29375. * @param reserved Internal use only
  29376. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  29377. */
  29378. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  29379. /**
  29380. * Remove a task from the assets manager.
  29381. * @param task the task to remove
  29382. */
  29383. removeTask(task: AbstractAssetTask): void;
  29384. private _decreaseWaitingTasksCount;
  29385. private _runTask;
  29386. /**
  29387. * Reset the {BABYLON.AssetsManager} and remove all tasks
  29388. * @return the current instance of the {BABYLON.AssetsManager}
  29389. */
  29390. reset(): AssetsManager;
  29391. /**
  29392. * Start the loading process
  29393. * @return the current instance of the {BABYLON.AssetsManager}
  29394. */
  29395. load(): AssetsManager;
  29396. }
  29397. }
  29398. declare module BABYLON {
  29399. /**
  29400. * Class used to enable access to IndexedDB
  29401. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  29402. */
  29403. class Database {
  29404. private callbackManifestChecked;
  29405. private currentSceneUrl;
  29406. private db;
  29407. private _enableSceneOffline;
  29408. private _enableTexturesOffline;
  29409. private manifestVersionFound;
  29410. private mustUpdateRessources;
  29411. private hasReachedQuota;
  29412. private isSupported;
  29413. private idbFactory;
  29414. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29415. static IsUASupportingBlobStorage: boolean;
  29416. /** Gets a boolean indicating if Database storate is enabled */
  29417. static IDBStorageEnabled: boolean;
  29418. /**
  29419. * Gets a boolean indicating if scene must be saved in the database
  29420. */
  29421. readonly enableSceneOffline: boolean;
  29422. /**
  29423. * Gets a boolean indicating if textures must be saved in the database
  29424. */
  29425. readonly enableTexturesOffline: boolean;
  29426. /**
  29427. * Creates a new Database
  29428. * @param urlToScene defines the url to load the scene
  29429. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29430. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29431. */
  29432. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29433. private static _ParseURL;
  29434. private static _ReturnFullUrlLocation;
  29435. private _checkManifestFile;
  29436. /**
  29437. * Open the database and make it available
  29438. * @param successCallback defines the callback to call on success
  29439. * @param errorCallback defines the callback to call on error
  29440. */
  29441. openAsync(successCallback: () => void, errorCallback: () => void): void;
  29442. /**
  29443. * Loads an image from the database
  29444. * @param url defines the url to load from
  29445. * @param image defines the target DOM image
  29446. */
  29447. loadImageFromDB(url: string, image: HTMLImageElement): void;
  29448. private _loadImageFromDBAsync;
  29449. private _saveImageIntoDBAsync;
  29450. private _checkVersionFromDB;
  29451. private _loadVersionFromDBAsync;
  29452. private _saveVersionIntoDBAsync;
  29453. /**
  29454. * Loads a file from database
  29455. * @param url defines the URL to load from
  29456. * @param sceneLoaded defines a callback to call on success
  29457. * @param progressCallBack defines a callback to call when progress changed
  29458. * @param errorCallback defines a callback to call on error
  29459. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29460. */
  29461. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29462. private _loadFileFromDBAsync;
  29463. private _saveFileIntoDBAsync;
  29464. }
  29465. }
  29466. declare module BABYLON {
  29467. interface DDSInfo {
  29468. width: number;
  29469. height: number;
  29470. mipmapCount: number;
  29471. isFourCC: boolean;
  29472. isRGB: boolean;
  29473. isLuminance: boolean;
  29474. isCube: boolean;
  29475. isCompressed: boolean;
  29476. dxgiFormat: number;
  29477. textureType: number;
  29478. /** Sphericle polynomial created for the dds texture */
  29479. sphericalPolynomial?: SphericalPolynomial;
  29480. }
  29481. class DDSTools {
  29482. static StoreLODInAlphaChannel: boolean;
  29483. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  29484. private static _FloatView;
  29485. private static _Int32View;
  29486. private static _ToHalfFloat;
  29487. private static _FromHalfFloat;
  29488. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  29489. private static _GetHalfFloatRGBAArrayBuffer;
  29490. private static _GetFloatRGBAArrayBuffer;
  29491. private static _GetFloatAsUIntRGBAArrayBuffer;
  29492. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  29493. private static _GetRGBAArrayBuffer;
  29494. private static _ExtractLongWordOrder;
  29495. private static _GetRGBArrayBuffer;
  29496. private static _GetLuminanceArrayBuffer;
  29497. /**
  29498. * Uploads DDS Levels to a Babylon Texture
  29499. * @hidden
  29500. */
  29501. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  29502. }
  29503. }
  29504. declare module BABYLON {
  29505. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29506. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29507. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29508. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29509. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29510. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29511. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29512. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29513. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29514. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29515. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29516. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29517. /**
  29518. * Decorator used to define property that can be serialized as reference to a camera
  29519. * @param sourceName defines the name of the property to decorate
  29520. */
  29521. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29522. class SerializationHelper {
  29523. static Serialize<T>(entity: T, serializationObject?: any): any;
  29524. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29525. static Clone<T>(creationFunction: () => T, source: T): T;
  29526. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29527. }
  29528. }
  29529. declare module BABYLON {
  29530. /**
  29531. * Wrapper class for promise with external resolve and reject.
  29532. */
  29533. class Deferred<T> {
  29534. /**
  29535. * The promise associated with this deferred object.
  29536. */
  29537. readonly promise: Promise<T>;
  29538. private _resolve;
  29539. private _reject;
  29540. /**
  29541. * The resolve method of the promise associated with this deferred object.
  29542. */
  29543. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  29544. /**
  29545. * The reject method of the promise associated with this deferred object.
  29546. */
  29547. readonly reject: (reason?: any) => void;
  29548. /**
  29549. * Constructor for this deferred object.
  29550. */
  29551. constructor();
  29552. }
  29553. }
  29554. declare module BABYLON {
  29555. /**
  29556. * Raw texture data and descriptor sufficient for WebGL texture upload
  29557. */
  29558. interface EnvironmentTextureInfo {
  29559. /**
  29560. * Version of the environment map
  29561. */
  29562. version: number;
  29563. /**
  29564. * Width of image
  29565. */
  29566. width: number;
  29567. /**
  29568. * Irradiance information stored in the file.
  29569. */
  29570. irradiance: any;
  29571. /**
  29572. * Specular information stored in the file.
  29573. */
  29574. specular: any;
  29575. }
  29576. /**
  29577. * Sets of helpers addressing the serialization and deserialization of environment texture
  29578. * stored in a BabylonJS env file.
  29579. * Those files are usually stored as .env files.
  29580. */
  29581. class EnvironmentTextureTools {
  29582. /**
  29583. * Magic number identifying the env file.
  29584. */
  29585. private static _MagicBytes;
  29586. /**
  29587. * Gets the environment info from an env file.
  29588. * @param data The array buffer containing the .env bytes.
  29589. * @returns the environment file info (the json header) if successfully parsed.
  29590. */
  29591. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  29592. /**
  29593. * Creates an environment texture from a loaded cube texture.
  29594. * @param texture defines the cube texture to convert in env file
  29595. * @return a promise containing the environment data if succesfull.
  29596. */
  29597. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  29598. /**
  29599. * Creates a JSON representation of the spherical data.
  29600. * @param texture defines the texture containing the polynomials
  29601. * @return the JSON representation of the spherical info
  29602. */
  29603. private static _CreateEnvTextureIrradiance;
  29604. /**
  29605. * Uploads the texture info contained in the env file to the GPU.
  29606. * @param texture defines the internal texture to upload to
  29607. * @param arrayBuffer defines the buffer cotaining the data to load
  29608. * @param info defines the texture info retrieved through the GetEnvInfo method
  29609. * @returns a promise
  29610. */
  29611. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  29612. /**
  29613. * Uploads the levels of image data to the GPU.
  29614. * @param texture defines the internal texture to upload to
  29615. * @param imageData defines the array buffer views of image data [mipmap][face]
  29616. * @returns a promise
  29617. */
  29618. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  29619. /**
  29620. * Uploads spherical polynomials information to the texture.
  29621. * @param texture defines the texture we are trying to upload the information to
  29622. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  29623. */
  29624. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  29625. }
  29626. }
  29627. declare module BABYLON {
  29628. class FilesInput {
  29629. static FilesToLoad: {
  29630. [key: string]: File;
  29631. };
  29632. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  29633. private _engine;
  29634. private _currentScene;
  29635. private _sceneLoadedCallback;
  29636. private _progressCallback;
  29637. private _additionalRenderLoopLogicCallback;
  29638. private _textureLoadingCallback;
  29639. private _startingProcessingFilesCallback;
  29640. private _onReloadCallback;
  29641. private _errorCallback;
  29642. private _elementToMonitor;
  29643. private _sceneFileToLoad;
  29644. private _filesToLoad;
  29645. 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);
  29646. private _dragEnterHandler;
  29647. private _dragOverHandler;
  29648. private _dropHandler;
  29649. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  29650. dispose(): void;
  29651. private renderFunction;
  29652. private drag;
  29653. private drop;
  29654. private _traverseFolder;
  29655. private _processFiles;
  29656. loadFiles(event: any): void;
  29657. private _processReload;
  29658. reload(): void;
  29659. }
  29660. }
  29661. declare module BABYLON {
  29662. /**
  29663. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29664. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29665. */
  29666. class KhronosTextureContainer {
  29667. arrayBuffer: any;
  29668. static HEADER_LEN: number;
  29669. static COMPRESSED_2D: number;
  29670. static COMPRESSED_3D: number;
  29671. static TEX_2D: number;
  29672. static TEX_3D: number;
  29673. glType: number;
  29674. glTypeSize: number;
  29675. glFormat: number;
  29676. glInternalFormat: number;
  29677. glBaseInternalFormat: number;
  29678. pixelWidth: number;
  29679. pixelHeight: number;
  29680. pixelDepth: number;
  29681. numberOfArrayElements: number;
  29682. numberOfFaces: number;
  29683. numberOfMipmapLevels: number;
  29684. bytesOfKeyValueData: number;
  29685. loadType: number;
  29686. /**
  29687. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  29688. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  29689. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  29690. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  29691. */
  29692. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  29693. switchEndainness(val: number): number;
  29694. /**
  29695. * Uploads KTX content to a Babylon Texture.
  29696. * It is assumed that the texture has already been created & is currently bound
  29697. * @hidden
  29698. */
  29699. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  29700. private _upload2DCompressedLevels;
  29701. }
  29702. }
  29703. declare module BABYLON {
  29704. /**
  29705. * A class serves as a medium between the observable and its observers
  29706. */
  29707. class EventState {
  29708. /**
  29709. * Create a new EventState
  29710. * @param mask defines the mask associated with this state
  29711. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29712. * @param target defines the original target of the state
  29713. * @param currentTarget defines the current target of the state
  29714. */
  29715. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  29716. /**
  29717. * Initialize the current event state
  29718. * @param mask defines the mask associated with this state
  29719. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29720. * @param target defines the original target of the state
  29721. * @param currentTarget defines the current target of the state
  29722. * @returns the current event state
  29723. */
  29724. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  29725. /**
  29726. * An Observer can set this property to true to prevent subsequent observers of being notified
  29727. */
  29728. skipNextObservers: boolean;
  29729. /**
  29730. * Get the mask value that were used to trigger the event corresponding to this EventState object
  29731. */
  29732. mask: number;
  29733. /**
  29734. * The object that originally notified the event
  29735. */
  29736. target?: any;
  29737. /**
  29738. * The current object in the bubbling phase
  29739. */
  29740. currentTarget?: any;
  29741. /**
  29742. * This will be populated with the return value of the last function that was executed.
  29743. * If it is the first function in the callback chain it will be the event data.
  29744. */
  29745. lastReturnValue?: any;
  29746. }
  29747. /**
  29748. * Represent an Observer registered to a given Observable object.
  29749. */
  29750. class Observer<T> {
  29751. /**
  29752. * Defines the callback to call when the observer is notified
  29753. */
  29754. callback: (eventData: T, eventState: EventState) => void;
  29755. /**
  29756. * Defines the mask of the observer (used to filter notifications)
  29757. */
  29758. mask: number;
  29759. /**
  29760. * Defines the current scope used to restore the JS context
  29761. */
  29762. scope: any;
  29763. /** @hidden */
  29764. _willBeUnregistered: boolean;
  29765. /**
  29766. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  29767. */
  29768. unregisterOnNextCall: boolean;
  29769. /**
  29770. * Creates a new observer
  29771. * @param callback defines the callback to call when the observer is notified
  29772. * @param mask defines the mask of the observer (used to filter notifications)
  29773. * @param scope defines the current scope used to restore the JS context
  29774. */
  29775. constructor(
  29776. /**
  29777. * Defines the callback to call when the observer is notified
  29778. */
  29779. callback: (eventData: T, eventState: EventState) => void,
  29780. /**
  29781. * Defines the mask of the observer (used to filter notifications)
  29782. */
  29783. mask: number,
  29784. /**
  29785. * Defines the current scope used to restore the JS context
  29786. */
  29787. scope?: any);
  29788. }
  29789. /**
  29790. * Represent a list of observers registered to multiple Observables object.
  29791. */
  29792. class MultiObserver<T> {
  29793. private _observers;
  29794. private _observables;
  29795. /**
  29796. * Release associated resources
  29797. */
  29798. dispose(): void;
  29799. /**
  29800. * Raise a callback when one of the observable will notify
  29801. * @param observables defines a list of observables to watch
  29802. * @param callback defines the callback to call on notification
  29803. * @param mask defines the mask used to filter notifications
  29804. * @param scope defines the current scope used to restore the JS context
  29805. * @returns the new MultiObserver
  29806. */
  29807. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  29808. }
  29809. /**
  29810. * The Observable class is a simple implementation of the Observable pattern.
  29811. *
  29812. * 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.
  29813. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  29814. * 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).
  29815. * 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.
  29816. */
  29817. class Observable<T> {
  29818. private _observers;
  29819. private _eventState;
  29820. private _onObserverAdded;
  29821. /**
  29822. * Creates a new observable
  29823. * @param onObserverAdded defines a callback to call when a new observer is added
  29824. */
  29825. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  29826. /**
  29827. * Create a new Observer with the specified callback
  29828. * @param callback the callback that will be executed for that Observer
  29829. * @param mask the mask used to filter observers
  29830. * @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.
  29831. * @param scope optional scope for the callback to be called from
  29832. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  29833. * @returns the new observer created for the callback
  29834. */
  29835. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  29836. /**
  29837. * Create a new Observer with the specified callback and unregisters after the next notification
  29838. * @param callback the callback that will be executed for that Observer
  29839. * @returns the new observer created for the callback
  29840. */
  29841. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  29842. /**
  29843. * Remove an Observer from the Observable object
  29844. * @param observer the instance of the Observer to remove
  29845. * @returns false if it doesn't belong to this Observable
  29846. */
  29847. remove(observer: Nullable<Observer<T>>): boolean;
  29848. /**
  29849. * Remove a callback from the Observable object
  29850. * @param callback the callback to remove
  29851. * @param scope optional scope. If used only the callbacks with this scope will be removed
  29852. * @returns false if it doesn't belong to this Observable
  29853. */
  29854. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  29855. private _deferUnregister;
  29856. private _remove;
  29857. /**
  29858. * Notify all Observers by calling their respective callback with the given data
  29859. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  29860. * @param eventData defines the data to send to all observers
  29861. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  29862. * @param target defines the original target of the state
  29863. * @param currentTarget defines the current target of the state
  29864. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  29865. */
  29866. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  29867. /**
  29868. * Calling this will execute each callback, expecting it to be a promise or return a value.
  29869. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  29870. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  29871. * and it is crucial that all callbacks will be executed.
  29872. * The order of the callbacks is kept, callbacks are not executed parallel.
  29873. *
  29874. * @param eventData The data to be sent to each callback
  29875. * @param mask is used to filter observers defaults to -1
  29876. * @param target defines the callback target (see EventState)
  29877. * @param currentTarget defines he current object in the bubbling phase
  29878. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  29879. */
  29880. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  29881. /**
  29882. * Notify a specific observer
  29883. * @param observer defines the observer to notify
  29884. * @param eventData defines the data to be sent to each callback
  29885. * @param mask is used to filter observers defaults to -1
  29886. */
  29887. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  29888. /**
  29889. * Gets a boolean indicating if the observable has at least one observer
  29890. * @returns true is the Observable has at least one Observer registered
  29891. */
  29892. hasObservers(): boolean;
  29893. /**
  29894. * Clear the list of observers
  29895. */
  29896. clear(): void;
  29897. /**
  29898. * Clone the current observable
  29899. * @returns a new observable
  29900. */
  29901. clone(): Observable<T>;
  29902. /**
  29903. * Does this observable handles observer registered with a given mask
  29904. * @param mask defines the mask to be tested
  29905. * @return whether or not one observer registered with the given mask is handeled
  29906. **/
  29907. hasSpecificMask(mask?: number): boolean;
  29908. }
  29909. }
  29910. declare module BABYLON {
  29911. /**
  29912. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  29913. */
  29914. class PerformanceMonitor {
  29915. private _enabled;
  29916. private _rollingFrameTime;
  29917. private _lastFrameTimeMs;
  29918. /**
  29919. * constructor
  29920. * @param frameSampleSize The number of samples required to saturate the sliding window
  29921. */
  29922. constructor(frameSampleSize?: number);
  29923. /**
  29924. * Samples current frame
  29925. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  29926. */
  29927. sampleFrame(timeMs?: number): void;
  29928. /**
  29929. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29930. * @return Average frame time in milliseconds
  29931. */
  29932. readonly averageFrameTime: number;
  29933. /**
  29934. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29935. * @return Frame time variance in milliseconds squared
  29936. */
  29937. readonly averageFrameTimeVariance: number;
  29938. /**
  29939. * Returns the frame time of the most recent frame
  29940. * @return Frame time in milliseconds
  29941. */
  29942. readonly instantaneousFrameTime: number;
  29943. /**
  29944. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  29945. * @return Framerate in frames per second
  29946. */
  29947. readonly averageFPS: number;
  29948. /**
  29949. * Returns the average framerate in frames per second using the most recent frame time
  29950. * @return Framerate in frames per second
  29951. */
  29952. readonly instantaneousFPS: number;
  29953. /**
  29954. * Returns true if enough samples have been taken to completely fill the sliding window
  29955. * @return true if saturated
  29956. */
  29957. readonly isSaturated: boolean;
  29958. /**
  29959. * Enables contributions to the sliding window sample set
  29960. */
  29961. enable(): void;
  29962. /**
  29963. * Disables contributions to the sliding window sample set
  29964. * Samples will not be interpolated over the disabled period
  29965. */
  29966. disable(): void;
  29967. /**
  29968. * Returns true if sampling is enabled
  29969. * @return true if enabled
  29970. */
  29971. readonly isEnabled: boolean;
  29972. /**
  29973. * Resets performance monitor
  29974. */
  29975. reset(): void;
  29976. }
  29977. /**
  29978. * RollingAverage
  29979. *
  29980. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  29981. */
  29982. class RollingAverage {
  29983. /**
  29984. * Current average
  29985. */
  29986. average: number;
  29987. /**
  29988. * Current variance
  29989. */
  29990. variance: number;
  29991. protected _samples: Array<number>;
  29992. protected _sampleCount: number;
  29993. protected _pos: number;
  29994. protected _m2: number;
  29995. /**
  29996. * constructor
  29997. * @param length The number of samples required to saturate the sliding window
  29998. */
  29999. constructor(length: number);
  30000. /**
  30001. * Adds a sample to the sample set
  30002. * @param v The sample value
  30003. */
  30004. add(v: number): void;
  30005. /**
  30006. * Returns previously added values or null if outside of history or outside the sliding window domain
  30007. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30008. * @return Value previously recorded with add() or null if outside of range
  30009. */
  30010. history(i: number): number;
  30011. /**
  30012. * Returns true if enough samples have been taken to completely fill the sliding window
  30013. * @return true if sample-set saturated
  30014. */
  30015. isSaturated(): boolean;
  30016. /**
  30017. * Resets the rolling average (equivalent to 0 samples taken so far)
  30018. */
  30019. reset(): void;
  30020. /**
  30021. * Wraps a value around the sample range boundaries
  30022. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30023. * @return Wrapped position in sample range
  30024. */
  30025. protected _wrapPosition(i: number): number;
  30026. }
  30027. }
  30028. declare module BABYLON {
  30029. /**
  30030. * Helper class that provides a small promise polyfill
  30031. */
  30032. class PromisePolyfill {
  30033. /**
  30034. * Static function used to check if the polyfill is required
  30035. * If this is the case then the function will inject the polyfill to window.Promise
  30036. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  30037. */
  30038. static Apply(force?: boolean): void;
  30039. }
  30040. }
  30041. declare module BABYLON {
  30042. /**
  30043. * Defines the root class used to create scene optimization to use with SceneOptimizer
  30044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30045. */
  30046. class SceneOptimization {
  30047. /**
  30048. * Defines the priority of this optimization (0 by default which means first in the list)
  30049. */
  30050. priority: number;
  30051. /**
  30052. * Gets a string describing the action executed by the current optimization
  30053. * @returns description string
  30054. */
  30055. getDescription(): string;
  30056. /**
  30057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30058. * @param scene defines the current scene where to apply this optimization
  30059. * @param optimizer defines the current optimizer
  30060. * @returns true if everything that can be done was applied
  30061. */
  30062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30063. /**
  30064. * Creates the SceneOptimization object
  30065. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30066. * @param desc defines the description associated with the optimization
  30067. */
  30068. constructor(
  30069. /**
  30070. * Defines the priority of this optimization (0 by default which means first in the list)
  30071. */
  30072. priority?: number);
  30073. }
  30074. /**
  30075. * Defines an optimization used to reduce the size of render target textures
  30076. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30077. */
  30078. class TextureOptimization extends SceneOptimization {
  30079. /**
  30080. * Defines the priority of this optimization (0 by default which means first in the list)
  30081. */
  30082. priority: number;
  30083. /**
  30084. * 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
  30085. */
  30086. maximumSize: number;
  30087. /**
  30088. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30089. */
  30090. step: number;
  30091. /**
  30092. * Gets a string describing the action executed by the current optimization
  30093. * @returns description string
  30094. */
  30095. getDescription(): string;
  30096. /**
  30097. * Creates the TextureOptimization object
  30098. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30099. * @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
  30100. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30101. */
  30102. constructor(
  30103. /**
  30104. * Defines the priority of this optimization (0 by default which means first in the list)
  30105. */
  30106. priority?: number,
  30107. /**
  30108. * 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
  30109. */
  30110. maximumSize?: number,
  30111. /**
  30112. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30113. */
  30114. step?: number);
  30115. /**
  30116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30117. * @param scene defines the current scene where to apply this optimization
  30118. * @param optimizer defines the current optimizer
  30119. * @returns true if everything that can be done was applied
  30120. */
  30121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30122. }
  30123. /**
  30124. * Defines an optimization used to increase or decrease the rendering resolution
  30125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30126. */
  30127. class HardwareScalingOptimization extends SceneOptimization {
  30128. /**
  30129. * Defines the priority of this optimization (0 by default which means first in the list)
  30130. */
  30131. priority: number;
  30132. /**
  30133. * Defines the maximum scale to use (2 by default)
  30134. */
  30135. maximumScale: number;
  30136. /**
  30137. * Defines the step to use between two passes (0.5 by default)
  30138. */
  30139. step: number;
  30140. private _currentScale;
  30141. private _directionOffset;
  30142. /**
  30143. * Gets a string describing the action executed by the current optimization
  30144. * @return description string
  30145. */
  30146. getDescription(): string;
  30147. /**
  30148. * Creates the HardwareScalingOptimization object
  30149. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30150. * @param maximumScale defines the maximum scale to use (2 by default)
  30151. * @param step defines the step to use between two passes (0.5 by default)
  30152. */
  30153. constructor(
  30154. /**
  30155. * Defines the priority of this optimization (0 by default which means first in the list)
  30156. */
  30157. priority?: number,
  30158. /**
  30159. * Defines the maximum scale to use (2 by default)
  30160. */
  30161. maximumScale?: number,
  30162. /**
  30163. * Defines the step to use between two passes (0.5 by default)
  30164. */
  30165. step?: number);
  30166. /**
  30167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30168. * @param scene defines the current scene where to apply this optimization
  30169. * @param optimizer defines the current optimizer
  30170. * @returns true if everything that can be done was applied
  30171. */
  30172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30173. }
  30174. /**
  30175. * Defines an optimization used to remove shadows
  30176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30177. */
  30178. class ShadowsOptimization extends SceneOptimization {
  30179. /**
  30180. * Gets a string describing the action executed by the current optimization
  30181. * @return description string
  30182. */
  30183. getDescription(): string;
  30184. /**
  30185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30186. * @param scene defines the current scene where to apply this optimization
  30187. * @param optimizer defines the current optimizer
  30188. * @returns true if everything that can be done was applied
  30189. */
  30190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30191. }
  30192. /**
  30193. * Defines an optimization used to turn post-processes off
  30194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30195. */
  30196. class PostProcessesOptimization extends SceneOptimization {
  30197. /**
  30198. * Gets a string describing the action executed by the current optimization
  30199. * @return description string
  30200. */
  30201. getDescription(): string;
  30202. /**
  30203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30204. * @param scene defines the current scene where to apply this optimization
  30205. * @param optimizer defines the current optimizer
  30206. * @returns true if everything that can be done was applied
  30207. */
  30208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30209. }
  30210. /**
  30211. * Defines an optimization used to turn lens flares off
  30212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30213. */
  30214. class LensFlaresOptimization extends SceneOptimization {
  30215. /**
  30216. * Gets a string describing the action executed by the current optimization
  30217. * @return description string
  30218. */
  30219. getDescription(): string;
  30220. /**
  30221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30222. * @param scene defines the current scene where to apply this optimization
  30223. * @param optimizer defines the current optimizer
  30224. * @returns true if everything that can be done was applied
  30225. */
  30226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30227. }
  30228. /**
  30229. * Defines an optimization based on user defined callback.
  30230. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30231. */
  30232. class CustomOptimization extends SceneOptimization {
  30233. /**
  30234. * Callback called to apply the custom optimization.
  30235. */
  30236. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  30237. /**
  30238. * Callback called to get custom description
  30239. */
  30240. onGetDescription: () => string;
  30241. /**
  30242. * Gets a string describing the action executed by the current optimization
  30243. * @returns description string
  30244. */
  30245. getDescription(): string;
  30246. /**
  30247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30248. * @param scene defines the current scene where to apply this optimization
  30249. * @param optimizer defines the current optimizer
  30250. * @returns true if everything that can be done was applied
  30251. */
  30252. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30253. }
  30254. /**
  30255. * Defines an optimization used to turn particles off
  30256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30257. */
  30258. class ParticlesOptimization extends SceneOptimization {
  30259. /**
  30260. * Gets a string describing the action executed by the current optimization
  30261. * @return description string
  30262. */
  30263. getDescription(): string;
  30264. /**
  30265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30266. * @param scene defines the current scene where to apply this optimization
  30267. * @param optimizer defines the current optimizer
  30268. * @returns true if everything that can be done was applied
  30269. */
  30270. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30271. }
  30272. /**
  30273. * Defines an optimization used to turn render targets off
  30274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30275. */
  30276. class RenderTargetsOptimization extends SceneOptimization {
  30277. /**
  30278. * Gets a string describing the action executed by the current optimization
  30279. * @return description string
  30280. */
  30281. getDescription(): string;
  30282. /**
  30283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30284. * @param scene defines the current scene where to apply this optimization
  30285. * @param optimizer defines the current optimizer
  30286. * @returns true if everything that can be done was applied
  30287. */
  30288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30289. }
  30290. /**
  30291. * Defines an optimization used to merge meshes with compatible materials
  30292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30293. */
  30294. class MergeMeshesOptimization extends SceneOptimization {
  30295. private static _UpdateSelectionTree;
  30296. /**
  30297. * Gets or sets a boolean which defines if optimization octree has to be updated
  30298. */
  30299. /**
  30300. * Gets or sets a boolean which defines if optimization octree has to be updated
  30301. */
  30302. static UpdateSelectionTree: boolean;
  30303. /**
  30304. * Gets a string describing the action executed by the current optimization
  30305. * @return description string
  30306. */
  30307. getDescription(): string;
  30308. private _canBeMerged;
  30309. /**
  30310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30311. * @param scene defines the current scene where to apply this optimization
  30312. * @param optimizer defines the current optimizer
  30313. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  30314. * @returns true if everything that can be done was applied
  30315. */
  30316. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  30317. }
  30318. /**
  30319. * Defines a list of options used by SceneOptimizer
  30320. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30321. */
  30322. class SceneOptimizerOptions {
  30323. /**
  30324. * Defines the target frame rate to reach (60 by default)
  30325. */
  30326. targetFrameRate: number;
  30327. /**
  30328. * Defines the interval between two checkes (2000ms by default)
  30329. */
  30330. trackerDuration: number;
  30331. /**
  30332. * Gets the list of optimizations to apply
  30333. */
  30334. optimizations: SceneOptimization[];
  30335. /**
  30336. * Creates a new list of options used by SceneOptimizer
  30337. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  30338. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  30339. */
  30340. constructor(
  30341. /**
  30342. * Defines the target frame rate to reach (60 by default)
  30343. */
  30344. targetFrameRate?: number,
  30345. /**
  30346. * Defines the interval between two checkes (2000ms by default)
  30347. */
  30348. trackerDuration?: number);
  30349. /**
  30350. * Add a new optimization
  30351. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  30352. * @returns the current SceneOptimizerOptions
  30353. */
  30354. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  30355. /**
  30356. * Add a new custom optimization
  30357. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  30358. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  30359. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30360. * @returns the current SceneOptimizerOptions
  30361. */
  30362. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  30363. /**
  30364. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  30365. * @param targetFrameRate defines the target frame rate (60 by default)
  30366. * @returns a SceneOptimizerOptions object
  30367. */
  30368. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30369. /**
  30370. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  30371. * @param targetFrameRate defines the target frame rate (60 by default)
  30372. * @returns a SceneOptimizerOptions object
  30373. */
  30374. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30375. /**
  30376. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  30377. * @param targetFrameRate defines the target frame rate (60 by default)
  30378. * @returns a SceneOptimizerOptions object
  30379. */
  30380. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30381. }
  30382. /**
  30383. * Class used to run optimizations in order to reach a target frame rate
  30384. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30385. */
  30386. class SceneOptimizer implements IDisposable {
  30387. private _isRunning;
  30388. private _options;
  30389. private _scene;
  30390. private _currentPriorityLevel;
  30391. private _targetFrameRate;
  30392. private _trackerDuration;
  30393. private _currentFrameRate;
  30394. private _sceneDisposeObserver;
  30395. private _improvementMode;
  30396. /**
  30397. * Defines an observable called when the optimizer reaches the target frame rate
  30398. */
  30399. onSuccessObservable: Observable<SceneOptimizer>;
  30400. /**
  30401. * Defines an observable called when the optimizer enables an optimization
  30402. */
  30403. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  30404. /**
  30405. * Defines an observable called when the optimizer is not able to reach the target frame rate
  30406. */
  30407. onFailureObservable: Observable<SceneOptimizer>;
  30408. /**
  30409. * Gets a boolean indicating if the optimizer is in improvement mode
  30410. */
  30411. readonly isInImprovementMode: boolean;
  30412. /**
  30413. * Gets the current priority level (0 at start)
  30414. */
  30415. readonly currentPriorityLevel: number;
  30416. /**
  30417. * Gets the current frame rate checked by the SceneOptimizer
  30418. */
  30419. readonly currentFrameRate: number;
  30420. /**
  30421. * Gets or sets the current target frame rate (60 by default)
  30422. */
  30423. /**
  30424. * Gets or sets the current target frame rate (60 by default)
  30425. */
  30426. targetFrameRate: number;
  30427. /**
  30428. * Gets or sets the current interval between two checks (every 2000ms by default)
  30429. */
  30430. /**
  30431. * Gets or sets the current interval between two checks (every 2000ms by default)
  30432. */
  30433. trackerDuration: number;
  30434. /**
  30435. * Gets the list of active optimizations
  30436. */
  30437. readonly optimizations: SceneOptimization[];
  30438. /**
  30439. * Creates a new SceneOptimizer
  30440. * @param scene defines the scene to work on
  30441. * @param options defines the options to use with the SceneOptimizer
  30442. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  30443. * @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)
  30444. */
  30445. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  30446. /**
  30447. * Stops the current optimizer
  30448. */
  30449. stop(): void;
  30450. /**
  30451. * Reset the optimizer to initial step (current priority level = 0)
  30452. */
  30453. reset(): void;
  30454. /**
  30455. * Start the optimizer. By default it will try to reach a specific framerate
  30456. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  30457. */
  30458. start(): void;
  30459. private _checkCurrentState;
  30460. /**
  30461. * Release all resources
  30462. */
  30463. dispose(): void;
  30464. /**
  30465. * Helper function to create a SceneOptimizer with one single line of code
  30466. * @param scene defines the scene to work on
  30467. * @param options defines the options to use with the SceneOptimizer
  30468. * @param onSuccess defines a callback to call on success
  30469. * @param onFailure defines a callback to call on failure
  30470. * @returns the new SceneOptimizer object
  30471. */
  30472. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  30473. }
  30474. }
  30475. declare module BABYLON {
  30476. class SceneSerializer {
  30477. static ClearCache(): void;
  30478. static Serialize(scene: Scene): any;
  30479. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  30480. }
  30481. }
  30482. declare module BABYLON {
  30483. class SmartArray<T> {
  30484. data: Array<T>;
  30485. length: number;
  30486. protected _id: number;
  30487. [index: number]: T;
  30488. constructor(capacity: number);
  30489. push(value: T): void;
  30490. forEach(func: (content: T) => void): void;
  30491. sort(compareFn: (a: T, b: T) => number): void;
  30492. reset(): void;
  30493. dispose(): void;
  30494. concat(array: any): void;
  30495. indexOf(value: T): number;
  30496. contains(value: T): boolean;
  30497. private static _GlobalId;
  30498. }
  30499. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  30500. private _duplicateId;
  30501. [index: number]: T;
  30502. push(value: T): void;
  30503. pushNoDuplicate(value: T): boolean;
  30504. reset(): void;
  30505. concatWithNoDuplicate(array: any): void;
  30506. }
  30507. }
  30508. declare module BABYLON {
  30509. /**
  30510. * This class implement a typical dictionary using a string as key and the generic type T as value.
  30511. * The underlying implementation relies on an associative array to ensure the best performances.
  30512. * The value can be anything including 'null' but except 'undefined'
  30513. */
  30514. class StringDictionary<T> {
  30515. /**
  30516. * This will clear this dictionary and copy the content from the 'source' one.
  30517. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  30518. * @param source the dictionary to take the content from and copy to this dictionary
  30519. */
  30520. copyFrom(source: StringDictionary<T>): void;
  30521. /**
  30522. * Get a value based from its key
  30523. * @param key the given key to get the matching value from
  30524. * @return the value if found, otherwise undefined is returned
  30525. */
  30526. get(key: string): T | undefined;
  30527. /**
  30528. * Get a value from its key or add it if it doesn't exist.
  30529. * This method will ensure you that a given key/data will be present in the dictionary.
  30530. * @param key the given key to get the matching value from
  30531. * @param factory the factory that will create the value if the key is not present in the dictionary.
  30532. * The factory will only be invoked if there's no data for the given key.
  30533. * @return the value corresponding to the key.
  30534. */
  30535. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  30536. /**
  30537. * Get a value from its key if present in the dictionary otherwise add it
  30538. * @param key the key to get the value from
  30539. * @param val if there's no such key/value pair in the dictionary add it with this value
  30540. * @return the value corresponding to the key
  30541. */
  30542. getOrAdd(key: string, val: T): T;
  30543. /**
  30544. * Check if there's a given key in the dictionary
  30545. * @param key the key to check for
  30546. * @return true if the key is present, false otherwise
  30547. */
  30548. contains(key: string): boolean;
  30549. /**
  30550. * Add a new key and its corresponding value
  30551. * @param key the key to add
  30552. * @param value the value corresponding to the key
  30553. * @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
  30554. */
  30555. add(key: string, value: T): boolean;
  30556. set(key: string, value: T): boolean;
  30557. /**
  30558. * Get the element of the given key and remove it from the dictionary
  30559. * @param key
  30560. */
  30561. getAndRemove(key: string): Nullable<T>;
  30562. /**
  30563. * Remove a key/value from the dictionary.
  30564. * @param key the key to remove
  30565. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  30566. */
  30567. remove(key: string): boolean;
  30568. /**
  30569. * Clear the whole content of the dictionary
  30570. */
  30571. clear(): void;
  30572. readonly count: number;
  30573. /**
  30574. * Execute a callback on each key/val of the dictionary.
  30575. * Note that you can remove any element in this dictionary in the callback implementation
  30576. * @param callback the callback to execute on a given key/value pair
  30577. */
  30578. forEach(callback: (key: string, val: T) => void): void;
  30579. /**
  30580. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  30581. * If the callback returns null or undefined the method will iterate to the next key/value pair
  30582. * Note that you can remove any element in this dictionary in the callback implementation
  30583. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  30584. */
  30585. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  30586. private _count;
  30587. private _data;
  30588. }
  30589. }
  30590. declare module BABYLON {
  30591. class Tags {
  30592. static EnableFor(obj: any): void;
  30593. static DisableFor(obj: any): void;
  30594. static HasTags(obj: any): boolean;
  30595. static GetTags(obj: any, asString?: boolean): any;
  30596. static AddTagsTo(obj: any, tagsString: string): void;
  30597. static _AddTagTo(obj: any, tag: string): void;
  30598. static RemoveTagsFrom(obj: any, tagsString: string): void;
  30599. static _RemoveTagFrom(obj: any, tag: string): void;
  30600. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  30601. }
  30602. }
  30603. declare module BABYLON {
  30604. class TextureTools {
  30605. /**
  30606. * Uses the GPU to create a copy texture rescaled at a given size
  30607. * @param texture Texture to copy from
  30608. * @param width Desired width
  30609. * @param height Desired height
  30610. * @return Generated texture
  30611. */
  30612. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  30613. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  30614. private static _environmentBRDFBase64Texture;
  30615. }
  30616. }
  30617. declare module BABYLON {
  30618. class TGATools {
  30619. private static _TYPE_INDEXED;
  30620. private static _TYPE_RGB;
  30621. private static _TYPE_GREY;
  30622. private static _TYPE_RLE_INDEXED;
  30623. private static _TYPE_RLE_RGB;
  30624. private static _TYPE_RLE_GREY;
  30625. private static _ORIGIN_MASK;
  30626. private static _ORIGIN_SHIFT;
  30627. private static _ORIGIN_BL;
  30628. private static _ORIGIN_BR;
  30629. private static _ORIGIN_UL;
  30630. private static _ORIGIN_UR;
  30631. static GetTGAHeader(data: Uint8Array): any;
  30632. /**
  30633. * Uploads TGA content to a Babylon Texture
  30634. * @hidden
  30635. */
  30636. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  30637. 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;
  30638. 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;
  30639. 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;
  30640. 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;
  30641. 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;
  30642. 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;
  30643. }
  30644. }
  30645. declare module BABYLON {
  30646. interface IAnimatable {
  30647. animations: Array<Animation>;
  30648. }
  30649. /** Interface used by value gradients (color, factor, ...) */
  30650. interface IValueGradient {
  30651. /**
  30652. * Gets or sets the gradient value (between 0 and 1)
  30653. */
  30654. gradient: number;
  30655. }
  30656. /** Class used to store color gradient */
  30657. class ColorGradient implements IValueGradient {
  30658. /**
  30659. * Gets or sets the gradient value (between 0 and 1)
  30660. */
  30661. gradient: number;
  30662. /**
  30663. * Gets or sets first associated color
  30664. */
  30665. color1: Color4;
  30666. /**
  30667. * Gets or sets second associated color
  30668. */
  30669. color2?: Color4;
  30670. /**
  30671. * Will get a color picked randomly between color1 and color2.
  30672. * If color2 is undefined then color1 will be used
  30673. * @param result defines the target Color4 to store the result in
  30674. */
  30675. getColorToRef(result: Color4): void;
  30676. }
  30677. /** Class used to store factor gradient */
  30678. class FactorGradient implements IValueGradient {
  30679. /**
  30680. * Gets or sets the gradient value (between 0 and 1)
  30681. */
  30682. gradient: number;
  30683. /**
  30684. * Gets or sets first associated factor
  30685. */
  30686. factor1: number;
  30687. /**
  30688. * Gets or sets second associated factor
  30689. */
  30690. factor2?: number;
  30691. /**
  30692. * Will get a number picked randomly between factor1 and factor2.
  30693. * If factor2 is undefined then factor1 will be used
  30694. * @returns the picked number
  30695. */
  30696. getFactor(): number;
  30697. }
  30698. class LoadFileError extends Error {
  30699. request?: XMLHttpRequest | undefined;
  30700. private static _setPrototypeOf;
  30701. constructor(message: string, request?: XMLHttpRequest | undefined);
  30702. }
  30703. class RetryStrategy {
  30704. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30705. }
  30706. interface IFileRequest {
  30707. /**
  30708. * Raised when the request is complete (success or error).
  30709. */
  30710. onCompleteObservable: Observable<IFileRequest>;
  30711. /**
  30712. * Aborts the request for a file.
  30713. */
  30714. abort: () => void;
  30715. }
  30716. class Tools {
  30717. static BaseUrl: string;
  30718. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30719. /**
  30720. * Default behaviour for cors in the application.
  30721. * It can be a string if the expected behavior is identical in the entire app.
  30722. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30723. */
  30724. static CorsBehavior: string | ((url: string | string[]) => string);
  30725. static UseFallbackTexture: boolean;
  30726. /**
  30727. * Use this object to register external classes like custom textures or material
  30728. * to allow the laoders to instantiate them
  30729. */
  30730. static RegisteredExternalClasses: {
  30731. [key: string]: Object;
  30732. };
  30733. static fallbackTexture: string;
  30734. /**
  30735. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30736. * @param u defines the coordinate on X axis
  30737. * @param v defines the coordinate on Y axis
  30738. * @param width defines the width of the source data
  30739. * @param height defines the height of the source data
  30740. * @param pixels defines the source byte array
  30741. * @param color defines the output color
  30742. */
  30743. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30744. /**
  30745. * Interpolates between a and b via alpha
  30746. * @param a The lower value (returned when alpha = 0)
  30747. * @param b The upper value (returned when alpha = 1)
  30748. * @param alpha The interpolation-factor
  30749. * @return The mixed value
  30750. */
  30751. static Mix(a: number, b: number, alpha: number): number;
  30752. static Instantiate(className: string): any;
  30753. /**
  30754. * Provides a slice function that will work even on IE
  30755. * @param data defines the array to slice
  30756. * @param start defines the start of the data (optional)
  30757. * @param end defines the end of the data (optional)
  30758. * @returns the new sliced array
  30759. */
  30760. static Slice<T>(data: T, start?: number, end?: number): T;
  30761. static SetImmediate(action: () => void): void;
  30762. static IsExponentOfTwo(value: number): boolean;
  30763. private static _tmpFloatArray;
  30764. /**
  30765. * Returns the nearest 32-bit single precision float representation of a Number
  30766. * @param value A Number. If the parameter is of a different type, it will get converted
  30767. * to a number or to NaN if it cannot be converted
  30768. * @returns number
  30769. */
  30770. static FloatRound(value: number): number;
  30771. /**
  30772. * Find the next highest power of two.
  30773. * @param x Number to start search from.
  30774. * @return Next highest power of two.
  30775. */
  30776. static CeilingPOT(x: number): number;
  30777. /**
  30778. * Find the next lowest power of two.
  30779. * @param x Number to start search from.
  30780. * @return Next lowest power of two.
  30781. */
  30782. static FloorPOT(x: number): number;
  30783. /**
  30784. * Find the nearest power of two.
  30785. * @param x Number to start search from.
  30786. * @return Next nearest power of two.
  30787. */
  30788. static NearestPOT(x: number): number;
  30789. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30790. static GetFilename(path: string): string;
  30791. /**
  30792. * Extracts the "folder" part of a path (everything before the filename).
  30793. * @param uri The URI to extract the info from
  30794. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30795. * @returns The "folder" part of the path
  30796. */
  30797. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30798. static GetDOMTextContent(element: HTMLElement): string;
  30799. static ToDegrees(angle: number): number;
  30800. static ToRadians(angle: number): number;
  30801. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30802. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30803. minimum: Vector3;
  30804. maximum: Vector3;
  30805. };
  30806. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30807. minimum: Vector3;
  30808. maximum: Vector3;
  30809. };
  30810. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  30811. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  30812. minimum: Vector2;
  30813. maximum: Vector2;
  30814. };
  30815. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30816. static GetPointerPrefix(): string;
  30817. /**
  30818. * @param func - the function to be called
  30819. * @param requester - the object that will request the next frame. Falls back to window.
  30820. */
  30821. static QueueNewFrame(func: () => void, requester?: any): number;
  30822. static RequestFullscreen(element: HTMLElement): void;
  30823. static ExitFullscreen(): void;
  30824. static SetCorsBehavior(url: string | string[], element: {
  30825. crossOrigin: string | null;
  30826. }): void;
  30827. static CleanUrl(url: string): string;
  30828. static PreprocessUrl: (url: string) => string;
  30829. /**
  30830. * Loads an image as an HTMLImageElement.
  30831. * @param input url string, ArrayBuffer, or Blob to load
  30832. * @param onLoad callback called when the image successfully loads
  30833. * @param onError callback called when the image fails to load
  30834. * @param database database for caching
  30835. * @returns the HTMLImageElement of the loaded image
  30836. */
  30837. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  30838. 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;
  30839. /**
  30840. * Load a script (identified by an url). When the url returns, the
  30841. * content of this file is added into a new script element, attached to the DOM (body element)
  30842. */
  30843. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30844. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30845. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30846. static FileAsURL(content: string): string;
  30847. static Format(value: number, decimals?: number): string;
  30848. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30849. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30850. static IsEmpty(obj: any): boolean;
  30851. static RegisterTopRootEvents(events: {
  30852. name: string;
  30853. handler: Nullable<(e: FocusEvent) => any>;
  30854. }[]): void;
  30855. static UnregisterTopRootEvents(events: {
  30856. name: string;
  30857. handler: Nullable<(e: FocusEvent) => any>;
  30858. }[]): void;
  30859. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30860. /**
  30861. * Converts the canvas data to blob.
  30862. * This acts as a polyfill for browsers not supporting the to blob function.
  30863. * @param canvas Defines the canvas to extract the data from
  30864. * @param successCallback Defines the callback triggered once the data are available
  30865. * @param mimeType Defines the mime type of the result
  30866. */
  30867. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30868. /**
  30869. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30870. * @param successCallback Defines the callback triggered once the data are available
  30871. * @param mimeType Defines the mime type of the result
  30872. * @param fileName The filename to download. If present, the result will automatically be downloaded
  30873. */
  30874. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30875. /**
  30876. * Downloads a blob in the browser
  30877. * @param blob defines the blob to download
  30878. * @param fileName defines the name of the downloaded file
  30879. */
  30880. static Download(blob: Blob, fileName: string): void;
  30881. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30882. /**
  30883. * Generates an image screenshot from the specified camera.
  30884. *
  30885. * @param engine The engine to use for rendering
  30886. * @param camera The camera to use for rendering
  30887. * @param size This parameter can be set to a single number or to an object with the
  30888. * following (optional) properties: precision, width, height. If a single number is passed,
  30889. * it will be used for both width and height. If an object is passed, the screenshot size
  30890. * will be derived from the parameters. The precision property is a multiplier allowing
  30891. * rendering at a higher or lower resolution.
  30892. * @param successCallback The callback receives a single parameter which contains the
  30893. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30894. * src parameter of an <img> to display it.
  30895. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30896. * Check your browser for supported MIME types.
  30897. * @param samples Texture samples (default: 1)
  30898. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30899. * @param fileName A name for for the downloaded file.
  30900. * @constructor
  30901. */
  30902. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30903. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  30904. /**
  30905. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30906. * Be aware Math.random() could cause collisions, but:
  30907. * "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"
  30908. */
  30909. static RandomId(): string;
  30910. /**
  30911. * Test if the given uri is a base64 string.
  30912. * @param uri The uri to test
  30913. * @return True if the uri is a base64 string or false otherwise.
  30914. */
  30915. static IsBase64(uri: string): boolean;
  30916. /**
  30917. * Decode the given base64 uri.
  30918. * @param uri The uri to decode
  30919. * @return The decoded base64 data.
  30920. */
  30921. static DecodeBase64(uri: string): ArrayBuffer;
  30922. private static _NoneLogLevel;
  30923. private static _MessageLogLevel;
  30924. private static _WarningLogLevel;
  30925. private static _ErrorLogLevel;
  30926. private static _LogCache;
  30927. static errorsCount: number;
  30928. static OnNewCacheEntry: (entry: string) => void;
  30929. static readonly NoneLogLevel: number;
  30930. static readonly MessageLogLevel: number;
  30931. static readonly WarningLogLevel: number;
  30932. static readonly ErrorLogLevel: number;
  30933. static readonly AllLogLevel: number;
  30934. private static _AddLogEntry;
  30935. private static _FormatMessage;
  30936. private static _LogDisabled;
  30937. private static _LogEnabled;
  30938. private static _WarnDisabled;
  30939. private static _WarnEnabled;
  30940. private static _ErrorDisabled;
  30941. private static _ErrorEnabled;
  30942. static Log: (message: string) => void;
  30943. static Warn: (message: string) => void;
  30944. static Error: (message: string) => void;
  30945. static readonly LogCache: string;
  30946. static ClearLogCache(): void;
  30947. static LogLevels: number;
  30948. static IsWindowObjectExist(): boolean;
  30949. private static _PerformanceNoneLogLevel;
  30950. private static _PerformanceUserMarkLogLevel;
  30951. private static _PerformanceConsoleLogLevel;
  30952. private static _performance;
  30953. static readonly PerformanceNoneLogLevel: number;
  30954. static readonly PerformanceUserMarkLogLevel: number;
  30955. static readonly PerformanceConsoleLogLevel: number;
  30956. static PerformanceLogLevel: number;
  30957. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30958. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30959. static _StartUserMark(counterName: string, condition?: boolean): void;
  30960. static _EndUserMark(counterName: string, condition?: boolean): void;
  30961. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  30962. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  30963. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30964. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30965. static readonly Now: number;
  30966. /**
  30967. * This method will return the name of the class used to create the instance of the given object.
  30968. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30969. * @param object the object to get the class name from
  30970. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  30971. */
  30972. static GetClassName(object: any, isType?: boolean): string;
  30973. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30974. /**
  30975. * This method will return the name of the full name of the class, including its owning module (if any).
  30976. * 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).
  30977. * @param object the object to get the class name from
  30978. * @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.
  30979. */
  30980. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30981. /**
  30982. * 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.
  30983. * @param array
  30984. */
  30985. static arrayOrStringFeeder(array: any): (i: number) => number;
  30986. /**
  30987. * Compute the hashCode of a stream of number
  30988. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  30989. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  30990. * @return the hash code computed
  30991. */
  30992. static hashCodeFromStream(feeder: (index: number) => number): number;
  30993. /**
  30994. * Returns a promise that resolves after the given amount of time.
  30995. * @param delay Number of milliseconds to delay
  30996. * @returns Promise that resolves after the given amount of time
  30997. */
  30998. static DelayAsync(delay: number): Promise<void>;
  30999. /**
  31000. * Gets the current gradient from an array of IValueGradient
  31001. * @param ratio defines the current ratio to get
  31002. * @param gradients defines the array of IValueGradient
  31003. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31004. */
  31005. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31006. }
  31007. /**
  31008. * This class is used to track a performance counter which is number based.
  31009. * The user has access to many properties which give statistics of different nature
  31010. *
  31011. * The implementer can track two kinds of Performance Counter: time and count
  31012. * 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.
  31013. * 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.
  31014. */
  31015. class PerfCounter {
  31016. static Enabled: boolean;
  31017. /**
  31018. * Returns the smallest value ever
  31019. */
  31020. readonly min: number;
  31021. /**
  31022. * Returns the biggest value ever
  31023. */
  31024. readonly max: number;
  31025. /**
  31026. * Returns the average value since the performance counter is running
  31027. */
  31028. readonly average: number;
  31029. /**
  31030. * Returns the average value of the last second the counter was monitored
  31031. */
  31032. readonly lastSecAverage: number;
  31033. /**
  31034. * Returns the current value
  31035. */
  31036. readonly current: number;
  31037. readonly total: number;
  31038. readonly count: number;
  31039. constructor();
  31040. /**
  31041. * Call this method to start monitoring a new frame.
  31042. * 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.
  31043. */
  31044. fetchNewFrame(): void;
  31045. /**
  31046. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31047. * @param newCount the count value to add to the monitored count
  31048. * @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.
  31049. */
  31050. addCount(newCount: number, fetchResult: boolean): void;
  31051. /**
  31052. * Start monitoring this performance counter
  31053. */
  31054. beginMonitoring(): void;
  31055. /**
  31056. * Compute the time lapsed since the previous beginMonitoring() call.
  31057. * @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
  31058. */
  31059. endMonitoring(newFrame?: boolean): void;
  31060. private _fetchResult;
  31061. private _startMonitoringTime;
  31062. private _min;
  31063. private _max;
  31064. private _average;
  31065. private _current;
  31066. private _totalValueCount;
  31067. private _totalAccumulated;
  31068. private _lastSecAverage;
  31069. private _lastSecAccumulated;
  31070. private _lastSecTime;
  31071. private _lastSecValueCount;
  31072. }
  31073. /**
  31074. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31075. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31076. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31077. * @param name The name of the class, case should be preserved
  31078. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31079. */
  31080. function className(name: string, module?: string): (target: Object) => void;
  31081. /**
  31082. * An implementation of a loop for asynchronous functions.
  31083. */
  31084. class AsyncLoop {
  31085. iterations: number;
  31086. private _fn;
  31087. private _successCallback;
  31088. index: number;
  31089. private _done;
  31090. /**
  31091. * Constroctor.
  31092. * @param iterations the number of iterations.
  31093. * @param _fn the function to run each iteration
  31094. * @param _successCallback the callback that will be called upon succesful execution
  31095. * @param offset starting offset.
  31096. */
  31097. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  31098. /**
  31099. * Execute the next iteration. Must be called after the last iteration was finished.
  31100. */
  31101. executeNext(): void;
  31102. /**
  31103. * Break the loop and run the success callback.
  31104. */
  31105. breakLoop(): void;
  31106. /**
  31107. * Helper function
  31108. */
  31109. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  31110. /**
  31111. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31112. * @param iterations total number of iterations
  31113. * @param syncedIterations number of synchronous iterations in each async iteration.
  31114. * @param fn the function to call each iteration.
  31115. * @param callback a success call back that will be called when iterating stops.
  31116. * @param breakFunction a break condition (optional)
  31117. * @param timeout timeout settings for the setTimeout function. default - 0.
  31118. * @constructor
  31119. */
  31120. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  31121. }
  31122. }
  31123. interface HTMLCanvasElement {
  31124. /** Track wether a record is in progress */
  31125. isRecording: boolean;
  31126. /** Capture Stream method defined by some browsers */
  31127. captureStream(fps?: number): MediaStream;
  31128. }
  31129. interface MediaRecorder {
  31130. /** Starts recording */
  31131. start(timeSlice: number): void;
  31132. /** Stops recording */
  31133. stop(): void;
  31134. /** Event raised when an error arised. */
  31135. onerror: (event: ErrorEvent) => void;
  31136. /** Event raised when the recording stops. */
  31137. onstop: (event: Event) => void;
  31138. /** Event raised when a new chunk of data is available and should be tracked. */
  31139. ondataavailable: (event: Event) => void;
  31140. }
  31141. interface MediaRecorderOptions {
  31142. /** The mime type you want to use as the recording container for the new MediaRecorder */
  31143. mimeType?: string;
  31144. /** The chosen bitrate for the audio component of the media. */
  31145. audioBitsPerSecond?: number;
  31146. /** The chosen bitrate for the video component of the media. */
  31147. videoBitsPerSecond?: number;
  31148. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  31149. bitsPerSecond?: number;
  31150. }
  31151. interface MediaRecorderConstructor {
  31152. /**
  31153. * A reference to the prototype.
  31154. */
  31155. readonly prototype: MediaRecorder;
  31156. /**
  31157. * Creates a new MediaRecorder.
  31158. * @param stream Defines the stream to record.
  31159. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  31160. */
  31161. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  31162. }
  31163. /**
  31164. * MediaRecoreder object available in some browsers.
  31165. */
  31166. declare var MediaRecorder: MediaRecorderConstructor;
  31167. declare module BABYLON {
  31168. /**
  31169. * This represents the different options avilable for the video capture.
  31170. */
  31171. interface VideoRecorderOptions {
  31172. /** Defines the mime type of the video */
  31173. mimeType: string;
  31174. /** Defines the video the video should be recorded at */
  31175. fps: number;
  31176. /** Defines the chunk size for the recording data */
  31177. recordChunckSize: number;
  31178. }
  31179. /**
  31180. * This can helps recording videos from BabylonJS.
  31181. * This is based on the available WebRTC functionalities of the browser.
  31182. *
  31183. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  31184. */
  31185. class VideoRecorder {
  31186. private static readonly _defaultOptions;
  31187. /**
  31188. * Returns wehther or not the VideoRecorder is available in your browser.
  31189. * @param engine Defines the Babylon Engine to check the support for
  31190. * @returns true if supported otherwise false
  31191. */
  31192. static IsSupported(engine: Engine): boolean;
  31193. private readonly _options;
  31194. private _canvas;
  31195. private _mediaRecorder;
  31196. private _recordedChunks;
  31197. private _fileName;
  31198. private _resolve;
  31199. private _reject;
  31200. /**
  31201. * True wether a recording is already in progress.
  31202. */
  31203. readonly isRecording: boolean;
  31204. /**
  31205. * Create a new VideoCapture object which can help converting what you see in Babylon to
  31206. * a video file.
  31207. * @param engine Defines the BabylonJS Engine you wish to record
  31208. * @param options Defines options that can be used to customized the capture
  31209. */
  31210. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  31211. /**
  31212. * Stops the current recording before the default capture timeout passed in the startRecording
  31213. * functions.
  31214. */
  31215. stopRecording(): void;
  31216. /**
  31217. * Starts recording the canvas for a max duration specified in parameters.
  31218. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  31219. * @param maxDuration Defines the maximum recording time in seconds.
  31220. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  31221. * @return a promise callback at the end of the recording with the video data in Blob.
  31222. */
  31223. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  31224. /**
  31225. * Releases internal resources used during the recording.
  31226. */
  31227. dispose(): void;
  31228. private _handleDataAvailable;
  31229. private _handleError;
  31230. private _handleStop;
  31231. }
  31232. }
  31233. declare module BABYLON {
  31234. /**
  31235. * Defines the potential axis of a Joystick
  31236. */
  31237. enum JoystickAxis {
  31238. /** X axis */
  31239. X = 0,
  31240. /** Y axis */
  31241. Y = 1,
  31242. /** Z axis */
  31243. Z = 2
  31244. }
  31245. /**
  31246. * Class used to define virtual joystick (used in touch mode)
  31247. */
  31248. class VirtualJoystick {
  31249. /**
  31250. * Gets or sets a boolean indicating that left and right values must be inverted
  31251. */
  31252. reverseLeftRight: boolean;
  31253. /**
  31254. * Gets or sets a boolean indicating that up and down values must be inverted
  31255. */
  31256. reverseUpDown: boolean;
  31257. /**
  31258. * Gets the offset value for the position (ie. the change of the position value)
  31259. */
  31260. deltaPosition: Vector3;
  31261. /**
  31262. * Gets a boolean indicating if the virtual joystick was pressed
  31263. */
  31264. pressed: boolean;
  31265. private static _globalJoystickIndex;
  31266. private static vjCanvas;
  31267. private static vjCanvasContext;
  31268. private static vjCanvasWidth;
  31269. private static vjCanvasHeight;
  31270. private static halfWidth;
  31271. private _action;
  31272. private _axisTargetedByLeftAndRight;
  31273. private _axisTargetedByUpAndDown;
  31274. private _joystickSensibility;
  31275. private _inversedSensibility;
  31276. private _joystickPointerID;
  31277. private _joystickColor;
  31278. private _joystickPointerPos;
  31279. private _joystickPreviousPointerPos;
  31280. private _joystickPointerStartPos;
  31281. private _deltaJoystickVector;
  31282. private _leftJoystick;
  31283. private _touches;
  31284. private _onPointerDownHandlerRef;
  31285. private _onPointerMoveHandlerRef;
  31286. private _onPointerUpHandlerRef;
  31287. private _onResize;
  31288. /**
  31289. * Creates a new virtual joystick
  31290. * @param leftJoystick defines that the joystick is for left hand (false by default)
  31291. */
  31292. constructor(leftJoystick?: boolean);
  31293. /**
  31294. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  31295. * @param newJoystickSensibility defines the new sensibility
  31296. */
  31297. setJoystickSensibility(newJoystickSensibility: number): void;
  31298. private _onPointerDown;
  31299. private _onPointerMove;
  31300. private _onPointerUp;
  31301. /**
  31302. * Change the color of the virtual joystick
  31303. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  31304. */
  31305. setJoystickColor(newColor: string): void;
  31306. /**
  31307. * Defines a callback to call when the joystick is touched
  31308. * @param action defines the callback
  31309. */
  31310. setActionOnTouch(action: () => any): void;
  31311. /**
  31312. * Defines which axis you'd like to control for left & right
  31313. * @param axis defines the axis to use
  31314. */
  31315. setAxisForLeftRight(axis: JoystickAxis): void;
  31316. /**
  31317. * Defines which axis you'd like to control for up & down
  31318. * @param axis defines the axis to use
  31319. */
  31320. setAxisForUpDown(axis: JoystickAxis): void;
  31321. private _drawVirtualJoystick;
  31322. /**
  31323. * Release internal HTML canvas
  31324. */
  31325. releaseCanvas(): void;
  31326. }
  31327. }
  31328. declare module BABYLON {
  31329. /**
  31330. * Helper class to push actions to a pool of workers.
  31331. */
  31332. class WorkerPool implements IDisposable {
  31333. private _workerInfos;
  31334. private _pendingActions;
  31335. /**
  31336. * Constructor
  31337. * @param workers Array of workers to use for actions
  31338. */
  31339. constructor(workers: Array<Worker>);
  31340. /**
  31341. * Terminates all workers and clears any pending actions.
  31342. */
  31343. dispose(): void;
  31344. /**
  31345. * Pushes an action to the worker pool. If all the workers are active, the action will be
  31346. * pended until a worker has completed its action.
  31347. * @param action The action to perform. Call onComplete when the action is complete.
  31348. */
  31349. push(action: (worker: Worker, onComplete: () => void) => void): void;
  31350. private _execute;
  31351. }
  31352. }
  31353. declare module BABYLON {
  31354. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  31355. readonly name: string;
  31356. private _zoomStopsAnimation;
  31357. private _idleRotationSpeed;
  31358. private _idleRotationWaitTime;
  31359. private _idleRotationSpinupTime;
  31360. /**
  31361. * Sets the flag that indicates if user zooming should stop animation.
  31362. */
  31363. /**
  31364. * Gets the flag that indicates if user zooming should stop animation.
  31365. */
  31366. zoomStopsAnimation: boolean;
  31367. /**
  31368. * Sets the default speed at which the camera rotates around the model.
  31369. */
  31370. /**
  31371. * Gets the default speed at which the camera rotates around the model.
  31372. */
  31373. idleRotationSpeed: number;
  31374. /**
  31375. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  31376. */
  31377. /**
  31378. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  31379. */
  31380. idleRotationWaitTime: number;
  31381. /**
  31382. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31383. */
  31384. /**
  31385. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31386. */
  31387. idleRotationSpinupTime: number;
  31388. /**
  31389. * Gets a value indicating if the camera is currently rotating because of this behavior
  31390. */
  31391. readonly rotationInProgress: boolean;
  31392. private _onPrePointerObservableObserver;
  31393. private _onAfterCheckInputsObserver;
  31394. private _attachedCamera;
  31395. private _isPointerDown;
  31396. private _lastFrameTime;
  31397. private _lastInteractionTime;
  31398. private _cameraRotationSpeed;
  31399. init(): void;
  31400. attach(camera: ArcRotateCamera): void;
  31401. detach(): void;
  31402. /**
  31403. * Returns true if user is scrolling.
  31404. * @return true if user is scrolling.
  31405. */
  31406. private _userIsZooming;
  31407. private _lastFrameRadius;
  31408. private _shouldAnimationStopForInteraction;
  31409. /**
  31410. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31411. */
  31412. private _applyUserInteraction;
  31413. private _userIsMoving;
  31414. }
  31415. }
  31416. declare module BABYLON {
  31417. /**
  31418. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  31419. */
  31420. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  31421. readonly name: string;
  31422. /**
  31423. * The easing function used by animations
  31424. */
  31425. static EasingFunction: BackEase;
  31426. /**
  31427. * The easing mode used by animations
  31428. */
  31429. static EasingMode: number;
  31430. /**
  31431. * The duration of the animation, in milliseconds
  31432. */
  31433. transitionDuration: number;
  31434. /**
  31435. * Length of the distance animated by the transition when lower radius is reached
  31436. */
  31437. lowerRadiusTransitionRange: number;
  31438. /**
  31439. * Length of the distance animated by the transition when upper radius is reached
  31440. */
  31441. upperRadiusTransitionRange: number;
  31442. private _autoTransitionRange;
  31443. /**
  31444. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  31445. */
  31446. /**
  31447. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  31448. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  31449. */
  31450. autoTransitionRange: boolean;
  31451. private _attachedCamera;
  31452. private _onAfterCheckInputsObserver;
  31453. private _onMeshTargetChangedObserver;
  31454. init(): void;
  31455. attach(camera: ArcRotateCamera): void;
  31456. detach(): void;
  31457. private _radiusIsAnimating;
  31458. private _radiusBounceTransition;
  31459. private _animatables;
  31460. private _cachedWheelPrecision;
  31461. /**
  31462. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  31463. * @param radiusLimit The limit to check against.
  31464. * @return Bool to indicate if at limit.
  31465. */
  31466. private _isRadiusAtLimit;
  31467. /**
  31468. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  31469. * @param radiusDelta The delta by which to animate to. Can be negative.
  31470. */
  31471. private _applyBoundRadiusAnimation;
  31472. /**
  31473. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  31474. */
  31475. protected _clearAnimationLocks(): void;
  31476. /**
  31477. * Stops and removes all animations that have been applied to the camera
  31478. */
  31479. stopAllAnimations(): void;
  31480. }
  31481. }
  31482. declare module BABYLON {
  31483. class FramingBehavior implements Behavior<ArcRotateCamera> {
  31484. readonly name: string;
  31485. private _mode;
  31486. private _radiusScale;
  31487. private _positionScale;
  31488. private _defaultElevation;
  31489. private _elevationReturnTime;
  31490. private _elevationReturnWaitTime;
  31491. private _zoomStopsAnimation;
  31492. private _framingTime;
  31493. /**
  31494. * The easing function used by animations
  31495. */
  31496. static EasingFunction: ExponentialEase;
  31497. /**
  31498. * The easing mode used by animations
  31499. */
  31500. static EasingMode: number;
  31501. /**
  31502. * Sets the current mode used by the behavior
  31503. */
  31504. /**
  31505. * Gets current mode used by the behavior.
  31506. */
  31507. mode: number;
  31508. /**
  31509. * Sets the scale applied to the radius (1 by default)
  31510. */
  31511. /**
  31512. * Gets the scale applied to the radius
  31513. */
  31514. radiusScale: number;
  31515. /**
  31516. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31517. */
  31518. /**
  31519. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31520. */
  31521. positionScale: number;
  31522. /**
  31523. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31524. * behaviour is triggered, in radians.
  31525. */
  31526. /**
  31527. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31528. * behaviour is triggered, in radians.
  31529. */
  31530. defaultElevation: number;
  31531. /**
  31532. * Sets the time (in milliseconds) taken to return to the default beta position.
  31533. * Negative value indicates camera should not return to default.
  31534. */
  31535. /**
  31536. * Gets the time (in milliseconds) taken to return to the default beta position.
  31537. * Negative value indicates camera should not return to default.
  31538. */
  31539. elevationReturnTime: number;
  31540. /**
  31541. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31542. */
  31543. /**
  31544. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31545. */
  31546. elevationReturnWaitTime: number;
  31547. /**
  31548. * Sets the flag that indicates if user zooming should stop animation.
  31549. */
  31550. /**
  31551. * Gets the flag that indicates if user zooming should stop animation.
  31552. */
  31553. zoomStopsAnimation: boolean;
  31554. /**
  31555. * Sets the transition time when framing the mesh, in milliseconds
  31556. */
  31557. /**
  31558. * Gets the transition time when framing the mesh, in milliseconds
  31559. */
  31560. framingTime: number;
  31561. private _onPrePointerObservableObserver;
  31562. private _onAfterCheckInputsObserver;
  31563. private _onMeshTargetChangedObserver;
  31564. private _attachedCamera;
  31565. private _isPointerDown;
  31566. private _lastInteractionTime;
  31567. init(): void;
  31568. attach(camera: ArcRotateCamera): void;
  31569. detach(): void;
  31570. private _animatables;
  31571. private _betaIsAnimating;
  31572. private _betaTransition;
  31573. private _radiusTransition;
  31574. private _vectorTransition;
  31575. /**
  31576. * Targets the given mesh and updates zoom level accordingly.
  31577. * @param mesh The mesh to target.
  31578. * @param radius Optional. If a cached radius position already exists, overrides default.
  31579. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31580. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31581. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31582. */
  31583. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31584. /**
  31585. * Targets the given mesh with its children and updates zoom level accordingly.
  31586. * @param mesh The mesh to target.
  31587. * @param radius Optional. If a cached radius position already exists, overrides default.
  31588. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31589. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31590. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31591. */
  31592. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31593. /**
  31594. * Targets the given meshes with their children and updates zoom level accordingly.
  31595. * @param meshes The mesh to target.
  31596. * @param radius Optional. If a cached radius position already exists, overrides default.
  31597. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31598. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31599. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31600. */
  31601. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31602. /**
  31603. * Targets the given mesh and updates zoom level accordingly.
  31604. * @param mesh The mesh to target.
  31605. * @param radius Optional. If a cached radius position already exists, overrides default.
  31606. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31607. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31608. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31609. */
  31610. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31611. /**
  31612. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  31613. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  31614. * frustum width.
  31615. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  31616. * to fully enclose the mesh in the viewing frustum.
  31617. */
  31618. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  31619. /**
  31620. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  31621. * is automatically returned to its default position (expected to be above ground plane).
  31622. */
  31623. private _maintainCameraAboveGround;
  31624. /**
  31625. * Returns the frustum slope based on the canvas ratio and camera FOV
  31626. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  31627. */
  31628. private _getFrustumSlope;
  31629. /**
  31630. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  31631. */
  31632. private _clearAnimationLocks;
  31633. /**
  31634. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31635. */
  31636. private _applyUserInteraction;
  31637. /**
  31638. * Stops and removes all animations that have been applied to the camera
  31639. */
  31640. stopAllAnimations(): void;
  31641. /**
  31642. * Gets a value indicating if the user is moving the camera
  31643. */
  31644. readonly isUserIsMoving: boolean;
  31645. /**
  31646. * The camera can move all the way towards the mesh.
  31647. */
  31648. static IgnoreBoundsSizeMode: number;
  31649. /**
  31650. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  31651. */
  31652. static FitFrustumSidesMode: number;
  31653. }
  31654. }
  31655. declare module BABYLON {
  31656. /**
  31657. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  31658. */
  31659. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  31660. private ui;
  31661. /**
  31662. * The name of the behavior
  31663. */
  31664. name: string;
  31665. /**
  31666. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  31667. */
  31668. distanceAwayFromFace: number;
  31669. /**
  31670. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  31671. */
  31672. distanceAwayFromBottomOfFace: number;
  31673. private _faceVectors;
  31674. private _target;
  31675. private _scene;
  31676. private _onRenderObserver;
  31677. private _tmpMatrix;
  31678. private _tmpVector;
  31679. /**
  31680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  31681. * @param ui The transform node that should be attched to the mesh
  31682. */
  31683. constructor(ui: BABYLON.TransformNode);
  31684. /**
  31685. * Initializes the behavior
  31686. */
  31687. init(): void;
  31688. private _closestFace;
  31689. private _zeroVector;
  31690. private _lookAtTmpMatrix;
  31691. private _lookAtToRef;
  31692. /**
  31693. * Attaches the AttachToBoxBehavior to the passed in mesh
  31694. * @param target The mesh that the specified node will be attached to
  31695. */
  31696. attach(target: BABYLON.Mesh): void;
  31697. /**
  31698. * Detaches the behavior from the mesh
  31699. */
  31700. detach(): void;
  31701. }
  31702. }
  31703. declare module BABYLON {
  31704. /**
  31705. * A behavior that when attached to a mesh will allow the mesh to be scaled
  31706. */
  31707. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  31708. private _dragBehaviorA;
  31709. private _dragBehaviorB;
  31710. private _startDistance;
  31711. private _initialScale;
  31712. private _targetScale;
  31713. private _ownerNode;
  31714. private _sceneRenderObserver;
  31715. constructor();
  31716. /**
  31717. * The name of the behavior
  31718. */
  31719. readonly name: string;
  31720. /**
  31721. * Initializes the behavior
  31722. */
  31723. init(): void;
  31724. private _getCurrentDistance;
  31725. /**
  31726. * Attaches the scale behavior the passed in mesh
  31727. * @param ownerNode The mesh that will be scaled around once attached
  31728. */
  31729. attach(ownerNode: Mesh): void;
  31730. /**
  31731. * Detaches the behavior from the mesh
  31732. */
  31733. detach(): void;
  31734. }
  31735. }
  31736. declare module BABYLON {
  31737. /**
  31738. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  31739. */
  31740. class PointerDragBehavior implements Behavior<Mesh> {
  31741. private _attachedNode;
  31742. private _dragPlane;
  31743. private _scene;
  31744. private _pointerObserver;
  31745. private _beforeRenderObserver;
  31746. private static _planeScene;
  31747. /**
  31748. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  31749. */
  31750. maxDragAngle: number;
  31751. /**
  31752. * @hidden
  31753. */
  31754. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  31755. /**
  31756. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31757. */
  31758. currentDraggingPointerID: number;
  31759. /**
  31760. * The last position where the pointer hit the drag plane in world space
  31761. */
  31762. lastDragPosition: Vector3;
  31763. /**
  31764. * If the behavior is currently in a dragging state
  31765. */
  31766. dragging: boolean;
  31767. /**
  31768. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  31769. */
  31770. dragDeltaRatio: number;
  31771. /**
  31772. * If the drag plane orientation should be updated during the dragging (Default: true)
  31773. */
  31774. updateDragPlane: boolean;
  31775. private _debugMode;
  31776. private _moving;
  31777. /**
  31778. * Fires each time the attached mesh is dragged with the pointer
  31779. * * delta between last drag position and current drag position in world space
  31780. * * dragDistance along the drag axis
  31781. * * dragPlaneNormal normal of the current drag plane used during the drag
  31782. * * dragPlanePoint in world space where the drag intersects the drag plane
  31783. */
  31784. onDragObservable: Observable<{
  31785. delta: Vector3;
  31786. dragPlanePoint: Vector3;
  31787. dragPlaneNormal: Vector3;
  31788. dragDistance: number;
  31789. pointerId: number;
  31790. }>;
  31791. /**
  31792. * Fires each time a drag begins (eg. mouse down on mesh)
  31793. */
  31794. onDragStartObservable: Observable<{
  31795. dragPlanePoint: Vector3;
  31796. pointerId: number;
  31797. }>;
  31798. /**
  31799. * Fires each time a drag ends (eg. mouse release after drag)
  31800. */
  31801. onDragEndObservable: Observable<{
  31802. dragPlanePoint: Vector3;
  31803. pointerId: number;
  31804. }>;
  31805. /**
  31806. * If the attached mesh should be moved when dragged
  31807. */
  31808. moveAttached: boolean;
  31809. /**
  31810. * If the drag behavior will react to drag events (Default: true)
  31811. */
  31812. enabled: boolean;
  31813. /**
  31814. * If camera controls should be detached during the drag
  31815. */
  31816. detachCameraControls: boolean;
  31817. /**
  31818. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  31819. */
  31820. useObjectOrienationForDragging: boolean;
  31821. private _options;
  31822. /**
  31823. * Creates a pointer drag behavior that can be attached to a mesh
  31824. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  31825. */
  31826. constructor(options?: {
  31827. dragAxis?: Vector3;
  31828. dragPlaneNormal?: Vector3;
  31829. });
  31830. /**
  31831. * The name of the behavior
  31832. */
  31833. readonly name: string;
  31834. /**
  31835. * Initializes the behavior
  31836. */
  31837. init(): void;
  31838. private _tmpVector;
  31839. private _alternatePickedPoint;
  31840. private _worldDragAxis;
  31841. /**
  31842. * Attaches the drag behavior the passed in mesh
  31843. * @param ownerNode The mesh that will be dragged around once attached
  31844. */
  31845. attach(ownerNode: Mesh): void;
  31846. releaseDrag(): void;
  31847. private _pickWithRayOnDragPlane;
  31848. private _pointA;
  31849. private _pointB;
  31850. private _pointC;
  31851. private _lineA;
  31852. private _lineB;
  31853. private _localAxis;
  31854. private _lookAt;
  31855. private _updateDragPlanePosition;
  31856. /**
  31857. * Detaches the behavior from the mesh
  31858. */
  31859. detach(): void;
  31860. }
  31861. }
  31862. declare module BABYLON {
  31863. /**
  31864. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  31865. */
  31866. class SixDofDragBehavior implements Behavior<Mesh> {
  31867. private static _virtualScene;
  31868. private _ownerNode;
  31869. private _sceneRenderObserver;
  31870. private _scene;
  31871. private _targetPosition;
  31872. private _virtualOriginMesh;
  31873. private _virtualDragMesh;
  31874. private _pointerObserver;
  31875. private _moving;
  31876. private _startingOrientation;
  31877. /**
  31878. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  31879. */
  31880. private zDragFactor;
  31881. /**
  31882. * If the behavior is currently in a dragging state
  31883. */
  31884. dragging: boolean;
  31885. /**
  31886. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  31887. */
  31888. dragDeltaRatio: number;
  31889. /**
  31890. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31891. */
  31892. currentDraggingPointerID: number;
  31893. /**
  31894. * If camera controls should be detached during the drag
  31895. */
  31896. detachCameraControls: boolean;
  31897. constructor();
  31898. /**
  31899. * The name of the behavior
  31900. */
  31901. readonly name: string;
  31902. /**
  31903. * Initializes the behavior
  31904. */
  31905. init(): void;
  31906. /**
  31907. * Attaches the scale behavior the passed in mesh
  31908. * @param ownerNode The mesh that will be scaled around once attached
  31909. */
  31910. attach(ownerNode: Mesh): void;
  31911. /**
  31912. * Detaches the behavior from the mesh
  31913. */
  31914. detach(): void;
  31915. }
  31916. }
  31917. declare module BABYLON {
  31918. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  31919. camera: ArcRotateCamera;
  31920. gamepad: Nullable<Gamepad>;
  31921. private _onGamepadConnectedObserver;
  31922. private _onGamepadDisconnectedObserver;
  31923. gamepadRotationSensibility: number;
  31924. gamepadMoveSensibility: number;
  31925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31926. detachControl(element: Nullable<HTMLElement>): void;
  31927. checkInputs(): void;
  31928. getClassName(): string;
  31929. getSimpleName(): string;
  31930. }
  31931. }
  31932. declare module BABYLON {
  31933. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  31934. camera: ArcRotateCamera;
  31935. private _keys;
  31936. keysUp: number[];
  31937. keysDown: number[];
  31938. keysLeft: number[];
  31939. keysRight: number[];
  31940. keysReset: number[];
  31941. panningSensibility: number;
  31942. zoomingSensibility: number;
  31943. useAltToZoom: boolean;
  31944. private _ctrlPressed;
  31945. private _altPressed;
  31946. private _onCanvasBlurObserver;
  31947. private _onKeyboardObserver;
  31948. private _engine;
  31949. private _scene;
  31950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31951. detachControl(element: Nullable<HTMLElement>): void;
  31952. checkInputs(): void;
  31953. getClassName(): string;
  31954. getSimpleName(): string;
  31955. }
  31956. }
  31957. declare module BABYLON {
  31958. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  31959. camera: ArcRotateCamera;
  31960. private _wheel;
  31961. private _observer;
  31962. wheelPrecision: number;
  31963. /**
  31964. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  31965. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  31966. */
  31967. wheelDeltaPercentage: number;
  31968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31969. detachControl(element: Nullable<HTMLElement>): void;
  31970. getClassName(): string;
  31971. getSimpleName(): string;
  31972. }
  31973. }
  31974. declare module BABYLON {
  31975. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  31976. camera: ArcRotateCamera;
  31977. buttons: number[];
  31978. angularSensibilityX: number;
  31979. angularSensibilityY: number;
  31980. pinchPrecision: number;
  31981. /**
  31982. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  31983. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  31984. */
  31985. pinchDeltaPercentage: number;
  31986. panningSensibility: number;
  31987. multiTouchPanning: boolean;
  31988. multiTouchPanAndZoom: boolean;
  31989. private _isPanClick;
  31990. pinchInwards: boolean;
  31991. private _pointerInput;
  31992. private _observer;
  31993. private _onMouseMove;
  31994. private _onGestureStart;
  31995. private _onGesture;
  31996. private _MSGestureHandler;
  31997. private _onLostFocus;
  31998. private _onContextMenu;
  31999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32000. detachControl(element: Nullable<HTMLElement>): void;
  32001. getClassName(): string;
  32002. getSimpleName(): string;
  32003. }
  32004. }
  32005. declare module BABYLON {
  32006. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  32007. camera: ArcRotateCamera;
  32008. alphaCorrection: number;
  32009. betaCorrection: number;
  32010. gammaCorrection: number;
  32011. private _alpha;
  32012. private _gamma;
  32013. private _dirty;
  32014. private _deviceOrientationHandler;
  32015. constructor();
  32016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32017. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  32018. checkInputs(): void;
  32019. detachControl(element: Nullable<HTMLElement>): void;
  32020. getClassName(): string;
  32021. getSimpleName(): string;
  32022. }
  32023. }
  32024. declare module BABYLON {
  32025. /**
  32026. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  32027. * Screen rotation is taken into account.
  32028. */
  32029. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  32030. private _camera;
  32031. private _screenOrientationAngle;
  32032. private _constantTranform;
  32033. private _screenQuaternion;
  32034. private _alpha;
  32035. private _beta;
  32036. private _gamma;
  32037. constructor();
  32038. camera: FreeCamera;
  32039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32040. private _orientationChanged;
  32041. private _deviceOrientation;
  32042. detachControl(element: Nullable<HTMLElement>): void;
  32043. checkInputs(): void;
  32044. getClassName(): string;
  32045. getSimpleName(): string;
  32046. }
  32047. }
  32048. declare module BABYLON {
  32049. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  32050. camera: FreeCamera;
  32051. gamepad: Nullable<Gamepad>;
  32052. private _onGamepadConnectedObserver;
  32053. private _onGamepadDisconnectedObserver;
  32054. gamepadAngularSensibility: number;
  32055. gamepadMoveSensibility: number;
  32056. private _cameraTransform;
  32057. private _deltaTransform;
  32058. private _vector3;
  32059. private _vector2;
  32060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32061. detachControl(element: Nullable<HTMLElement>): void;
  32062. checkInputs(): void;
  32063. getClassName(): string;
  32064. getSimpleName(): string;
  32065. }
  32066. }
  32067. declare module BABYLON {
  32068. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  32069. camera: FreeCamera;
  32070. private _keys;
  32071. private _onCanvasBlurObserver;
  32072. private _onKeyboardObserver;
  32073. private _engine;
  32074. private _scene;
  32075. keysUp: number[];
  32076. keysDown: number[];
  32077. keysLeft: number[];
  32078. keysRight: number[];
  32079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32080. detachControl(element: Nullable<HTMLElement>): void;
  32081. checkInputs(): void;
  32082. getClassName(): string;
  32083. _onLostFocus(e: FocusEvent): void;
  32084. getSimpleName(): string;
  32085. }
  32086. }
  32087. declare module BABYLON {
  32088. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  32089. touchEnabled: boolean;
  32090. camera: FreeCamera;
  32091. buttons: number[];
  32092. angularSensibility: number;
  32093. private _pointerInput;
  32094. private _onMouseMove;
  32095. private _observer;
  32096. private previousPosition;
  32097. constructor(touchEnabled?: boolean);
  32098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32099. detachControl(element: Nullable<HTMLElement>): void;
  32100. getClassName(): string;
  32101. getSimpleName(): string;
  32102. }
  32103. }
  32104. declare module BABYLON {
  32105. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  32106. camera: FreeCamera;
  32107. private _offsetX;
  32108. private _offsetY;
  32109. private _pointerPressed;
  32110. private _pointerInput;
  32111. private _observer;
  32112. private _onLostFocus;
  32113. touchAngularSensibility: number;
  32114. touchMoveSensibility: number;
  32115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32116. detachControl(element: Nullable<HTMLElement>): void;
  32117. checkInputs(): void;
  32118. getClassName(): string;
  32119. getSimpleName(): string;
  32120. }
  32121. }
  32122. declare module BABYLON {
  32123. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  32124. camera: FreeCamera;
  32125. private _leftjoystick;
  32126. private _rightjoystick;
  32127. getLeftJoystick(): VirtualJoystick;
  32128. getRightJoystick(): VirtualJoystick;
  32129. checkInputs(): void;
  32130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32131. detachControl(element: Nullable<HTMLElement>): void;
  32132. getClassName(): string;
  32133. getSimpleName(): string;
  32134. }
  32135. }
  32136. declare module BABYLON {
  32137. /**
  32138. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  32139. */
  32140. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  32141. /**
  32142. * Creates a new AnaglyphArcRotateCamera
  32143. * @param name defines camera name
  32144. * @param alpha defines alpha angle (in radians)
  32145. * @param beta defines beta angle (in radians)
  32146. * @param radius defines radius
  32147. * @param target defines camera target
  32148. * @param interaxialDistance defines distance between each color axis
  32149. * @param scene defines the hosting scene
  32150. */
  32151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  32152. /**
  32153. * Gets camera class name
  32154. * @returns AnaglyphArcRotateCamera
  32155. */
  32156. getClassName(): string;
  32157. }
  32158. }
  32159. declare module BABYLON {
  32160. /**
  32161. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  32162. */
  32163. class AnaglyphFreeCamera extends FreeCamera {
  32164. /**
  32165. * Creates a new AnaglyphFreeCamera
  32166. * @param name defines camera name
  32167. * @param position defines initial position
  32168. * @param interaxialDistance defines distance between each color axis
  32169. * @param scene defines the hosting scene
  32170. */
  32171. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32172. /**
  32173. * Gets camera class name
  32174. * @returns AnaglyphFreeCamera
  32175. */
  32176. getClassName(): string;
  32177. }
  32178. }
  32179. declare module BABYLON {
  32180. /**
  32181. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  32182. */
  32183. class AnaglyphGamepadCamera extends GamepadCamera {
  32184. /**
  32185. * Creates a new AnaglyphGamepadCamera
  32186. * @param name defines camera name
  32187. * @param position defines initial position
  32188. * @param interaxialDistance defines distance between each color axis
  32189. * @param scene defines the hosting scene
  32190. */
  32191. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32192. /**
  32193. * Gets camera class name
  32194. * @returns AnaglyphGamepadCamera
  32195. */
  32196. getClassName(): string;
  32197. }
  32198. }
  32199. declare module BABYLON {
  32200. /**
  32201. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  32202. */
  32203. class AnaglyphUniversalCamera extends UniversalCamera {
  32204. /**
  32205. * Creates a new AnaglyphUniversalCamera
  32206. * @param name defines camera name
  32207. * @param position defines initial position
  32208. * @param interaxialDistance defines distance between each color axis
  32209. * @param scene defines the hosting scene
  32210. */
  32211. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32212. /**
  32213. * Gets camera class name
  32214. * @returns AnaglyphUniversalCamera
  32215. */
  32216. getClassName(): string;
  32217. }
  32218. }
  32219. declare module BABYLON {
  32220. /**
  32221. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  32222. */
  32223. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  32224. /**
  32225. * Creates a new StereoscopicArcRotateCamera
  32226. * @param name defines camera name
  32227. * @param alpha defines alpha angle (in radians)
  32228. * @param beta defines beta angle (in radians)
  32229. * @param radius defines radius
  32230. * @param target defines camera target
  32231. * @param interaxialDistance defines distance between each color axis
  32232. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32233. * @param scene defines the hosting scene
  32234. */
  32235. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32236. /**
  32237. * Gets camera class name
  32238. * @returns StereoscopicArcRotateCamera
  32239. */
  32240. getClassName(): string;
  32241. }
  32242. }
  32243. declare module BABYLON {
  32244. /**
  32245. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  32246. */
  32247. class StereoscopicFreeCamera extends FreeCamera {
  32248. /**
  32249. * Creates a new StereoscopicFreeCamera
  32250. * @param name defines camera name
  32251. * @param position defines initial position
  32252. * @param interaxialDistance defines distance between each color axis
  32253. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32254. * @param scene defines the hosting scene
  32255. */
  32256. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32257. /**
  32258. * Gets camera class name
  32259. * @returns StereoscopicFreeCamera
  32260. */
  32261. getClassName(): string;
  32262. }
  32263. }
  32264. declare module BABYLON {
  32265. /**
  32266. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  32267. */
  32268. class StereoscopicGamepadCamera extends GamepadCamera {
  32269. /**
  32270. * Creates a new StereoscopicGamepadCamera
  32271. * @param name defines camera name
  32272. * @param position defines initial position
  32273. * @param interaxialDistance defines distance between each color axis
  32274. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32275. * @param scene defines the hosting scene
  32276. */
  32277. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32278. /**
  32279. * Gets camera class name
  32280. * @returns StereoscopicGamepadCamera
  32281. */
  32282. getClassName(): string;
  32283. }
  32284. }
  32285. declare module BABYLON {
  32286. /**
  32287. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  32288. */
  32289. class StereoscopicUniversalCamera extends UniversalCamera {
  32290. /**
  32291. * Creates a new StereoscopicUniversalCamera
  32292. * @param name defines camera name
  32293. * @param position defines initial position
  32294. * @param interaxialDistance defines distance between each color axis
  32295. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32296. * @param scene defines the hosting scene
  32297. */
  32298. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32299. /**
  32300. * Gets camera class name
  32301. * @returns StereoscopicUniversalCamera
  32302. */
  32303. getClassName(): string;
  32304. }
  32305. }
  32306. declare module BABYLON {
  32307. class VRCameraMetrics {
  32308. hResolution: number;
  32309. vResolution: number;
  32310. hScreenSize: number;
  32311. vScreenSize: number;
  32312. vScreenCenter: number;
  32313. eyeToScreenDistance: number;
  32314. lensSeparationDistance: number;
  32315. interpupillaryDistance: number;
  32316. distortionK: number[];
  32317. chromaAbCorrection: number[];
  32318. postProcessScaleFactor: number;
  32319. lensCenterOffset: number;
  32320. compensateDistortion: boolean;
  32321. readonly aspectRatio: number;
  32322. readonly aspectRatioFov: number;
  32323. readonly leftHMatrix: Matrix;
  32324. readonly rightHMatrix: Matrix;
  32325. readonly leftPreViewMatrix: Matrix;
  32326. readonly rightPreViewMatrix: Matrix;
  32327. static GetDefault(): VRCameraMetrics;
  32328. }
  32329. }
  32330. declare module BABYLON {
  32331. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  32332. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32333. getClassName(): string;
  32334. }
  32335. }
  32336. declare module BABYLON {
  32337. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  32338. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32339. getClassName(): string;
  32340. }
  32341. }
  32342. declare module BABYLON {
  32343. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  32344. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32345. getClassName(): string;
  32346. }
  32347. }
  32348. declare module BABYLON {
  32349. /**
  32350. * Options to modify the vr teleportation behavior.
  32351. */
  32352. interface VRTeleportationOptions {
  32353. /**
  32354. * The name of the mesh which should be used as the teleportation floor. (default: null)
  32355. */
  32356. floorMeshName?: string;
  32357. /**
  32358. * A list of meshes to be used as the teleportation floor. (default: empty)
  32359. */
  32360. floorMeshes?: Mesh[];
  32361. }
  32362. /**
  32363. * Options to modify the vr experience helper's behavior.
  32364. */
  32365. interface VRExperienceHelperOptions extends WebVROptions {
  32366. /**
  32367. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  32368. */
  32369. createDeviceOrientationCamera?: boolean;
  32370. /**
  32371. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  32372. */
  32373. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  32374. /**
  32375. * Uses the main button on the controller to toggle the laser casted. (default: true)
  32376. */
  32377. laserToggle?: boolean;
  32378. /**
  32379. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  32380. */
  32381. floorMeshes?: Mesh[];
  32382. }
  32383. /**
  32384. * Helps to quickly add VR support to an existing scene.
  32385. * See http://doc.babylonjs.com/how_to/webvr_helper
  32386. */
  32387. class VRExperienceHelper {
  32388. /** Options to modify the vr experience helper's behavior. */
  32389. webVROptions: VRExperienceHelperOptions;
  32390. private _scene;
  32391. private _position;
  32392. private _btnVR;
  32393. private _btnVRDisplayed;
  32394. private _webVRsupported;
  32395. private _webVRready;
  32396. private _webVRrequesting;
  32397. private _webVRpresenting;
  32398. private _fullscreenVRpresenting;
  32399. private _canvas;
  32400. private _webVRCamera;
  32401. private _vrDeviceOrientationCamera;
  32402. private _deviceOrientationCamera;
  32403. private _existingCamera;
  32404. private _onKeyDown;
  32405. private _onVrDisplayPresentChange;
  32406. private _onVRDisplayChanged;
  32407. private _onVRRequestPresentStart;
  32408. private _onVRRequestPresentComplete;
  32409. /**
  32410. * Observable raised when entering VR.
  32411. */
  32412. onEnteringVRObservable: Observable<VRExperienceHelper>;
  32413. /**
  32414. * Observable raised when exiting VR.
  32415. */
  32416. onExitingVRObservable: Observable<VRExperienceHelper>;
  32417. /**
  32418. * Observable raised when controller mesh is loaded.
  32419. */
  32420. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32421. /** Return this.onEnteringVRObservable
  32422. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  32423. */
  32424. readonly onEnteringVR: Observable<VRExperienceHelper>;
  32425. /** Return this.onExitingVRObservable
  32426. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  32427. */
  32428. readonly onExitingVR: Observable<VRExperienceHelper>;
  32429. /** Return this.onControllerMeshLoadedObservable
  32430. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  32431. */
  32432. readonly onControllerMeshLoaded: Observable<WebVRController>;
  32433. private _rayLength;
  32434. private _useCustomVRButton;
  32435. private _teleportationRequested;
  32436. private _teleportActive;
  32437. private _floorMeshName;
  32438. private _floorMeshesCollection;
  32439. private _rotationAllowed;
  32440. private _teleportBackwardsVector;
  32441. private _teleportationTarget;
  32442. private _isDefaultTeleportationTarget;
  32443. private _postProcessMove;
  32444. private _teleportationFillColor;
  32445. private _teleportationBorderColor;
  32446. private _rotationAngle;
  32447. private _haloCenter;
  32448. private _cameraGazer;
  32449. private _padSensibilityUp;
  32450. private _padSensibilityDown;
  32451. private leftController;
  32452. private rightController;
  32453. /**
  32454. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  32455. */
  32456. onNewMeshSelected: Observable<AbstractMesh>;
  32457. /**
  32458. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  32459. */
  32460. onNewMeshPicked: Observable<PickingInfo>;
  32461. private _circleEase;
  32462. /**
  32463. * Observable raised before camera teleportation
  32464. */
  32465. onBeforeCameraTeleport: Observable<Vector3>;
  32466. /**
  32467. * Observable raised after camera teleportation
  32468. */
  32469. onAfterCameraTeleport: Observable<Vector3>;
  32470. /**
  32471. * Observable raised when current selected mesh gets unselected
  32472. */
  32473. onSelectedMeshUnselected: Observable<AbstractMesh>;
  32474. private _raySelectionPredicate;
  32475. /**
  32476. * To be optionaly changed by user to define custom ray selection
  32477. */
  32478. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  32479. /**
  32480. * To be optionaly changed by user to define custom selection logic (after ray selection)
  32481. */
  32482. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  32483. /**
  32484. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  32485. */
  32486. teleportationEnabled: boolean;
  32487. private _defaultHeight;
  32488. private _teleportationInitialized;
  32489. private _interactionsEnabled;
  32490. private _interactionsRequested;
  32491. private _displayGaze;
  32492. private _displayLaserPointer;
  32493. /**
  32494. * The mesh used to display where the user is going to teleport.
  32495. */
  32496. /**
  32497. * Sets the mesh to be used to display where the user is going to teleport.
  32498. */
  32499. teleportationTarget: Mesh;
  32500. /**
  32501. * The mesh used to display where the user is selecting,
  32502. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  32503. * See http://doc.babylonjs.com/resources/baking_transformations
  32504. */
  32505. gazeTrackerMesh: Mesh;
  32506. /**
  32507. * If the ray of the gaze should be displayed.
  32508. */
  32509. /**
  32510. * Sets if the ray of the gaze should be displayed.
  32511. */
  32512. displayGaze: boolean;
  32513. /**
  32514. * If the ray of the LaserPointer should be displayed.
  32515. */
  32516. /**
  32517. * Sets if the ray of the LaserPointer should be displayed.
  32518. */
  32519. displayLaserPointer: boolean;
  32520. /**
  32521. * The deviceOrientationCamera used as the camera when not in VR.
  32522. */
  32523. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  32524. /**
  32525. * Based on the current WebVR support, returns the current VR camera used.
  32526. */
  32527. readonly currentVRCamera: Nullable<Camera>;
  32528. /**
  32529. * The webVRCamera which is used when in VR.
  32530. */
  32531. readonly webVRCamera: WebVRFreeCamera;
  32532. /**
  32533. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  32534. */
  32535. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  32536. private readonly _teleportationRequestInitiated;
  32537. /**
  32538. * Instantiates a VRExperienceHelper.
  32539. * Helps to quickly add VR support to an existing scene.
  32540. * @param scene The scene the VRExperienceHelper belongs to.
  32541. * @param webVROptions Options to modify the vr experience helper's behavior.
  32542. */
  32543. constructor(scene: Scene,
  32544. /** Options to modify the vr experience helper's behavior. */
  32545. webVROptions?: VRExperienceHelperOptions);
  32546. private _onDefaultMeshLoaded;
  32547. private _onResize;
  32548. private _onFullscreenChange;
  32549. /**
  32550. * Gets a value indicating if we are currently in VR mode.
  32551. */
  32552. readonly isInVRMode: boolean;
  32553. private onVrDisplayPresentChange;
  32554. private onVRDisplayChanged;
  32555. private moveButtonToBottomRight;
  32556. private displayVRButton;
  32557. private updateButtonVisibility;
  32558. /**
  32559. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  32560. * Otherwise, will use the fullscreen API.
  32561. */
  32562. enterVR(): void;
  32563. /**
  32564. * Attempt to exit VR, or fullscreen.
  32565. */
  32566. exitVR(): void;
  32567. /**
  32568. * The position of the vr experience helper.
  32569. */
  32570. /**
  32571. * Sets the position of the vr experience helper.
  32572. */
  32573. position: Vector3;
  32574. /**
  32575. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  32576. */
  32577. enableInteractions(): void;
  32578. private readonly _noControllerIsActive;
  32579. private beforeRender;
  32580. private _isTeleportationFloor;
  32581. /**
  32582. * Adds a floor mesh to be used for teleportation.
  32583. * @param floorMesh the mesh to be used for teleportation.
  32584. */
  32585. addFloorMesh(floorMesh: Mesh): void;
  32586. /**
  32587. * Removes a floor mesh from being used for teleportation.
  32588. * @param floorMesh the mesh to be removed.
  32589. */
  32590. removeFloorMesh(floorMesh: Mesh): void;
  32591. /**
  32592. * Enables interactions and teleportation using the VR controllers and gaze.
  32593. * @param vrTeleportationOptions options to modify teleportation behavior.
  32594. */
  32595. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  32596. private _onNewGamepadConnected;
  32597. private _tryEnableInteractionOnController;
  32598. private _onNewGamepadDisconnected;
  32599. private _enableInteractionOnController;
  32600. private _checkTeleportWithRay;
  32601. private _checkRotate;
  32602. private _checkTeleportBackwards;
  32603. private _enableTeleportationOnController;
  32604. private _createTeleportationCircles;
  32605. private _displayTeleportationTarget;
  32606. private _hideTeleportationTarget;
  32607. private _rotateCamera;
  32608. private _moveTeleportationSelectorTo;
  32609. private _workingVector;
  32610. private _workingQuaternion;
  32611. private _workingMatrix;
  32612. private _teleportCamera;
  32613. private _convertNormalToDirectionOfRay;
  32614. private _castRayAndSelectObject;
  32615. private _notifySelectedMeshUnselected;
  32616. /**
  32617. * Sets the color of the laser ray from the vr controllers.
  32618. * @param color new color for the ray.
  32619. */
  32620. changeLaserColor(color: Color3): void;
  32621. /**
  32622. * Sets the color of the ray from the vr headsets gaze.
  32623. * @param color new color for the ray.
  32624. */
  32625. changeGazeColor(color: Color3): void;
  32626. /**
  32627. * Exits VR and disposes of the vr experience helper
  32628. */
  32629. dispose(): void;
  32630. /**
  32631. * Gets the name of the VRExperienceHelper class
  32632. * @returns "VRExperienceHelper"
  32633. */
  32634. getClassName(): string;
  32635. }
  32636. }
  32637. declare module BABYLON {
  32638. /**
  32639. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  32640. * IMPORTANT!! The data is right-hand data.
  32641. * @export
  32642. * @interface DevicePose
  32643. */
  32644. interface DevicePose {
  32645. /**
  32646. * The position of the device, values in array are [x,y,z].
  32647. */
  32648. readonly position: Nullable<Float32Array>;
  32649. /**
  32650. * The linearVelocity of the device, values in array are [x,y,z].
  32651. */
  32652. readonly linearVelocity: Nullable<Float32Array>;
  32653. /**
  32654. * The linearAcceleration of the device, values in array are [x,y,z].
  32655. */
  32656. readonly linearAcceleration: Nullable<Float32Array>;
  32657. /**
  32658. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  32659. */
  32660. readonly orientation: Nullable<Float32Array>;
  32661. /**
  32662. * The angularVelocity of the device, values in array are [x,y,z].
  32663. */
  32664. readonly angularVelocity: Nullable<Float32Array>;
  32665. /**
  32666. * The angularAcceleration of the device, values in array are [x,y,z].
  32667. */
  32668. readonly angularAcceleration: Nullable<Float32Array>;
  32669. }
  32670. /**
  32671. * Interface representing a pose controlled object in Babylon.
  32672. * A pose controlled object has both regular pose values as well as pose values
  32673. * from an external device such as a VR head mounted display
  32674. */
  32675. interface PoseControlled {
  32676. /**
  32677. * The position of the object in babylon space.
  32678. */
  32679. position: Vector3;
  32680. /**
  32681. * The rotation quaternion of the object in babylon space.
  32682. */
  32683. rotationQuaternion: Quaternion;
  32684. /**
  32685. * The position of the device in babylon space.
  32686. */
  32687. devicePosition?: Vector3;
  32688. /**
  32689. * The rotation quaternion of the device in babylon space.
  32690. */
  32691. deviceRotationQuaternion: Quaternion;
  32692. /**
  32693. * The raw pose coming from the device.
  32694. */
  32695. rawPose: Nullable<DevicePose>;
  32696. /**
  32697. * The scale of the device to be used when translating from device space to babylon space.
  32698. */
  32699. deviceScaleFactor: number;
  32700. /**
  32701. * Updates the poseControlled values based on the input device pose.
  32702. * @param poseData the pose data to update the object with
  32703. */
  32704. updateFromDevice(poseData: DevicePose): void;
  32705. }
  32706. /**
  32707. * Set of options to customize the webVRCamera
  32708. */
  32709. interface WebVROptions {
  32710. /**
  32711. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  32712. */
  32713. trackPosition?: boolean;
  32714. /**
  32715. * Sets the scale of the vrDevice in babylon space. (default: 1)
  32716. */
  32717. positionScale?: number;
  32718. /**
  32719. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  32720. */
  32721. displayName?: string;
  32722. /**
  32723. * Should the native controller meshes be initialized. (default: true)
  32724. */
  32725. controllerMeshes?: boolean;
  32726. /**
  32727. * Creating a default HemiLight only on controllers. (default: true)
  32728. */
  32729. defaultLightingOnControllers?: boolean;
  32730. /**
  32731. * If you don't want to use the default VR button of the helper. (default: false)
  32732. */
  32733. useCustomVRButton?: boolean;
  32734. /**
  32735. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  32736. */
  32737. customVRButton?: HTMLButtonElement;
  32738. /**
  32739. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  32740. */
  32741. rayLength?: number;
  32742. /**
  32743. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  32744. */
  32745. defaultHeight?: number;
  32746. }
  32747. /**
  32748. * This represents a WebVR camera.
  32749. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  32750. * @example http://doc.babylonjs.com/how_to/webvr_camera
  32751. */
  32752. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  32753. private webVROptions;
  32754. /**
  32755. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  32756. */
  32757. _vrDevice: any;
  32758. /**
  32759. * The rawPose of the vrDevice.
  32760. */
  32761. rawPose: Nullable<DevicePose>;
  32762. private _onVREnabled;
  32763. private _specsVersion;
  32764. private _attached;
  32765. private _frameData;
  32766. protected _descendants: Array<Node>;
  32767. private _deviceRoomPosition;
  32768. /** @hidden */
  32769. _deviceRoomRotationQuaternion: Quaternion;
  32770. private _standingMatrix;
  32771. /**
  32772. * Represents device position in babylon space.
  32773. */
  32774. devicePosition: Vector3;
  32775. /**
  32776. * Represents device rotation in babylon space.
  32777. */
  32778. deviceRotationQuaternion: Quaternion;
  32779. /**
  32780. * The scale of the device to be used when translating from device space to babylon space.
  32781. */
  32782. deviceScaleFactor: number;
  32783. private _deviceToWorld;
  32784. private _worldToDevice;
  32785. /**
  32786. * References to the webVR controllers for the vrDevice.
  32787. */
  32788. controllers: Array<WebVRController>;
  32789. /**
  32790. * Emits an event when a controller is attached.
  32791. */
  32792. onControllersAttachedObservable: Observable<WebVRController[]>;
  32793. /**
  32794. * Emits an event when a controller's mesh has been loaded;
  32795. */
  32796. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32797. /**
  32798. * Emits an event when the HMD's pose has been updated.
  32799. */
  32800. onPoseUpdatedFromDeviceObservable: Observable<any>;
  32801. private _poseSet;
  32802. /**
  32803. * If the rig cameras be used as parent instead of this camera.
  32804. */
  32805. rigParenting: boolean;
  32806. private _lightOnControllers;
  32807. private _defaultHeight?;
  32808. /**
  32809. * Instantiates a WebVRFreeCamera.
  32810. * @param name The name of the WebVRFreeCamera
  32811. * @param position The starting anchor position for the camera
  32812. * @param scene The scene the camera belongs to
  32813. * @param webVROptions a set of customizable options for the webVRCamera
  32814. */
  32815. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  32816. /**
  32817. * Gets the device distance from the ground in meters.
  32818. * @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.
  32819. */
  32820. deviceDistanceToRoomGround(): number;
  32821. /**
  32822. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32823. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  32824. */
  32825. useStandingMatrix(callback?: (bool: boolean) => void): void;
  32826. /**
  32827. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32828. * @returns A promise with a boolean set to if the standing matrix is supported.
  32829. */
  32830. useStandingMatrixAsync(): Promise<boolean>;
  32831. /**
  32832. * Disposes the camera
  32833. */
  32834. dispose(): void;
  32835. /**
  32836. * Gets a vrController by name.
  32837. * @param name The name of the controller to retreive
  32838. * @returns the controller matching the name specified or null if not found
  32839. */
  32840. getControllerByName(name: string): Nullable<WebVRController>;
  32841. private _leftController;
  32842. /**
  32843. * The controller corrisponding to the users left hand.
  32844. */
  32845. readonly leftController: Nullable<WebVRController>;
  32846. private _rightController;
  32847. /**
  32848. * The controller corrisponding to the users right hand.
  32849. */
  32850. readonly rightController: Nullable<WebVRController>;
  32851. /**
  32852. * Casts a ray forward from the vrCamera's gaze.
  32853. * @param length Length of the ray (default: 100)
  32854. * @returns the ray corrisponding to the gaze
  32855. */
  32856. getForwardRay(length?: number): Ray;
  32857. /**
  32858. * Updates the camera based on device's frame data
  32859. */
  32860. _checkInputs(): void;
  32861. /**
  32862. * Updates the poseControlled values based on the input device pose.
  32863. * @param poseData Pose coming from the device
  32864. */
  32865. updateFromDevice(poseData: DevicePose): void;
  32866. /**
  32867. * WebVR's attach control will start broadcasting frames to the device.
  32868. * Note that in certain browsers (chrome for example) this function must be called
  32869. * within a user-interaction callback. Example:
  32870. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  32871. *
  32872. * @param element html element to attach the vrDevice to
  32873. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  32874. */
  32875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32876. /**
  32877. * Detaches the camera from the html element and disables VR
  32878. *
  32879. * @param element html element to detach from
  32880. */
  32881. detachControl(element: HTMLElement): void;
  32882. /**
  32883. * @returns the name of this class
  32884. */
  32885. getClassName(): string;
  32886. /**
  32887. * Calls resetPose on the vrDisplay
  32888. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  32889. */
  32890. resetToCurrentRotation(): void;
  32891. /**
  32892. * Updates the rig cameras (left and right eye)
  32893. */
  32894. _updateRigCameras(): void;
  32895. private _workingVector;
  32896. private _oneVector;
  32897. private _workingMatrix;
  32898. private updateCacheCalled;
  32899. /**
  32900. * Updates the cached values of the camera
  32901. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  32902. */
  32903. _updateCache(ignoreParentClass?: boolean): void;
  32904. /**
  32905. * Updates the current device position and rotation in the babylon world
  32906. */
  32907. update(): void;
  32908. /**
  32909. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  32910. * @returns an identity matrix
  32911. */
  32912. _getViewMatrix(): Matrix;
  32913. /**
  32914. * This function is called by the two RIG cameras.
  32915. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  32916. */
  32917. protected _getWebVRViewMatrix(): Matrix;
  32918. protected _getWebVRProjectionMatrix(): Matrix;
  32919. private _onGamepadConnectedObserver;
  32920. private _onGamepadDisconnectedObserver;
  32921. /**
  32922. * Initializes the controllers and their meshes
  32923. */
  32924. initControllers(): void;
  32925. }
  32926. }
  32927. declare module BABYLON {
  32928. interface IOctreeContainer<T> {
  32929. blocks: Array<OctreeBlock<T>>;
  32930. }
  32931. class Octree<T> {
  32932. maxDepth: number;
  32933. blocks: Array<OctreeBlock<T>>;
  32934. dynamicContent: T[];
  32935. private _maxBlockCapacity;
  32936. private _selectionContent;
  32937. private _creationFunc;
  32938. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  32939. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  32940. addMesh(entry: T): void;
  32941. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  32942. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  32943. intersectsRay(ray: Ray): SmartArray<T>;
  32944. 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;
  32945. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  32946. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  32947. }
  32948. }
  32949. declare module BABYLON {
  32950. class OctreeBlock<T> {
  32951. entries: T[];
  32952. blocks: Array<OctreeBlock<T>>;
  32953. private _depth;
  32954. private _maxDepth;
  32955. private _capacity;
  32956. private _minPoint;
  32957. private _maxPoint;
  32958. private _boundingVectors;
  32959. private _creationFunc;
  32960. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  32961. readonly capacity: number;
  32962. readonly minPoint: Vector3;
  32963. readonly maxPoint: Vector3;
  32964. addEntry(entry: T): void;
  32965. addEntries(entries: T[]): void;
  32966. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  32967. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  32968. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  32969. createInnerBlocks(): void;
  32970. }
  32971. }
  32972. declare module BABYLON {
  32973. interface Engine {
  32974. /**
  32975. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  32976. * @return the new query
  32977. */
  32978. createQuery(): WebGLQuery;
  32979. /**
  32980. * Delete and release a webGL query
  32981. * @param query defines the query to delete
  32982. * @return the current engine
  32983. */
  32984. deleteQuery(query: WebGLQuery): Engine;
  32985. /**
  32986. * Check if a given query has resolved and got its value
  32987. * @param query defines the query to check
  32988. * @returns true if the query got its value
  32989. */
  32990. isQueryResultAvailable(query: WebGLQuery): boolean;
  32991. /**
  32992. * Gets the value of a given query
  32993. * @param query defines the query to check
  32994. * @returns the value of the query
  32995. */
  32996. getQueryResult(query: WebGLQuery): number;
  32997. /**
  32998. * Initiates an occlusion query
  32999. * @param algorithmType defines the algorithm to use
  33000. * @param query defines the query to use
  33001. * @returns the current engine
  33002. * @see http://doc.babylonjs.com/features/occlusionquery
  33003. */
  33004. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  33005. /**
  33006. * Ends an occlusion query
  33007. * @see http://doc.babylonjs.com/features/occlusionquery
  33008. * @param algorithmType defines the algorithm to use
  33009. * @returns the current engine
  33010. */
  33011. endOcclusionQuery(algorithmType: number): Engine;
  33012. /**
  33013. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  33014. * Please note that only one query can be issued at a time
  33015. * @returns a time token used to track the time span
  33016. */
  33017. startTimeQuery(): Nullable<_TimeToken>;
  33018. /**
  33019. * Ends a time query
  33020. * @param token defines the token used to measure the time span
  33021. * @returns the time spent (in ns)
  33022. */
  33023. endTimeQuery(token: _TimeToken): int;
  33024. /** @hidden */
  33025. _currentNonTimestampToken: Nullable<_TimeToken>;
  33026. /** @hidden */
  33027. _createTimeQuery(): WebGLQuery;
  33028. /** @hidden */
  33029. _deleteTimeQuery(query: WebGLQuery): void;
  33030. /** @hidden */
  33031. _getGlAlgorithmType(algorithmType: number): number;
  33032. /** @hidden */
  33033. _getTimeQueryResult(query: WebGLQuery): any;
  33034. /** @hidden */
  33035. _getTimeQueryAvailability(query: WebGLQuery): any;
  33036. }
  33037. }
  33038. declare module BABYLON {
  33039. interface Engine {
  33040. /**
  33041. * Creates a webGL transform feedback object
  33042. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  33043. * @returns the webGL transform feedback object
  33044. */
  33045. createTransformFeedback(): WebGLTransformFeedback;
  33046. /**
  33047. * Delete a webGL transform feedback object
  33048. * @param value defines the webGL transform feedback object to delete
  33049. */
  33050. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  33051. /**
  33052. * Bind a webGL transform feedback object to the webgl context
  33053. * @param value defines the webGL transform feedback object to bind
  33054. */
  33055. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  33056. /**
  33057. * Begins a transform feedback operation
  33058. * @param usePoints defines if points or triangles must be used
  33059. */
  33060. beginTransformFeedback(usePoints: boolean): void;
  33061. /**
  33062. * Ends a transform feedback operation
  33063. */
  33064. endTransformFeedback(): void;
  33065. /**
  33066. * Specify the varyings to use with transform feedback
  33067. * @param program defines the associated webGL program
  33068. * @param value defines the list of strings representing the varying names
  33069. */
  33070. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  33071. /**
  33072. * Bind a webGL buffer for a transform feedback operation
  33073. * @param value defines the webGL buffer to bind
  33074. */
  33075. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  33076. }
  33077. }
  33078. declare module BABYLON {
  33079. /**
  33080. * Google Daydream controller
  33081. */
  33082. class DaydreamController extends WebVRController {
  33083. /**
  33084. * Base Url for the controller model.
  33085. */
  33086. static MODEL_BASE_URL: string;
  33087. /**
  33088. * File name for the controller model.
  33089. */
  33090. static MODEL_FILENAME: string;
  33091. /**
  33092. * Gamepad Id prefix used to identify Daydream Controller.
  33093. */
  33094. static readonly GAMEPAD_ID_PREFIX: string;
  33095. /**
  33096. * Creates a new DaydreamController from a gamepad
  33097. * @param vrGamepad the gamepad that the controller should be created from
  33098. */
  33099. constructor(vrGamepad: any);
  33100. /**
  33101. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33102. * @param scene scene in which to add meshes
  33103. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33104. */
  33105. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33106. /**
  33107. * Called once for each button that changed state since the last frame
  33108. * @param buttonIdx Which button index changed
  33109. * @param state New state of the button
  33110. * @param changes Which properties on the state changed since last frame
  33111. */
  33112. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33113. }
  33114. }
  33115. declare module BABYLON {
  33116. /**
  33117. * Gear VR Controller
  33118. */
  33119. class GearVRController extends WebVRController {
  33120. /**
  33121. * Base Url for the controller model.
  33122. */
  33123. static MODEL_BASE_URL: string;
  33124. /**
  33125. * File name for the controller model.
  33126. */
  33127. static MODEL_FILENAME: string;
  33128. private _maxRotationDistFromHeadset;
  33129. private _draggedRoomRotation;
  33130. private _tmpVector;
  33131. /**
  33132. * Gamepad Id prefix used to identify this controller.
  33133. */
  33134. static readonly GAMEPAD_ID_PREFIX: string;
  33135. private readonly _buttonIndexToObservableNameMap;
  33136. /**
  33137. * Creates a new GearVRController from a gamepad
  33138. * @param vrGamepad the gamepad that the controller should be created from
  33139. */
  33140. constructor(vrGamepad: any);
  33141. /**
  33142. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  33143. * @param poseData raw pose fromthe device
  33144. */
  33145. updateFromDevice(poseData: DevicePose): void;
  33146. /**
  33147. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33148. * @param scene scene in which to add meshes
  33149. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33150. */
  33151. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33152. /**
  33153. * Called once for each button that changed state since the last frame
  33154. * @param buttonIdx Which button index changed
  33155. * @param state New state of the button
  33156. * @param changes Which properties on the state changed since last frame
  33157. */
  33158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33159. }
  33160. }
  33161. declare module BABYLON {
  33162. /**
  33163. * Generic Controller
  33164. */
  33165. class GenericController extends WebVRController {
  33166. /**
  33167. * Base Url for the controller model.
  33168. */
  33169. static readonly MODEL_BASE_URL: string;
  33170. /**
  33171. * File name for the controller model.
  33172. */
  33173. static readonly MODEL_FILENAME: string;
  33174. /**
  33175. * Creates a new GenericController from a gamepad
  33176. * @param vrGamepad the gamepad that the controller should be created from
  33177. */
  33178. constructor(vrGamepad: any);
  33179. /**
  33180. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33181. * @param scene scene in which to add meshes
  33182. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33183. */
  33184. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33185. /**
  33186. * Called once for each button that changed state since the last frame
  33187. * @param buttonIdx Which button index changed
  33188. * @param state New state of the button
  33189. * @param changes Which properties on the state changed since last frame
  33190. */
  33191. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33192. }
  33193. }
  33194. declare module BABYLON {
  33195. /**
  33196. * Oculus Touch Controller
  33197. */
  33198. class OculusTouchController extends WebVRController {
  33199. /**
  33200. * Base Url for the controller model.
  33201. */
  33202. static MODEL_BASE_URL: string;
  33203. /**
  33204. * File name for the left controller model.
  33205. */
  33206. static MODEL_LEFT_FILENAME: string;
  33207. /**
  33208. * File name for the right controller model.
  33209. */
  33210. static MODEL_RIGHT_FILENAME: string;
  33211. /**
  33212. * Fired when the secondary trigger on this controller is modified
  33213. */
  33214. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  33215. /**
  33216. * Fired when the thumb rest on this controller is modified
  33217. */
  33218. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  33219. /**
  33220. * Creates a new OculusTouchController from a gamepad
  33221. * @param vrGamepad the gamepad that the controller should be created from
  33222. */
  33223. constructor(vrGamepad: any);
  33224. /**
  33225. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33226. * @param scene scene in which to add meshes
  33227. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33228. */
  33229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33230. /**
  33231. * Fired when the A button on this controller is modified
  33232. */
  33233. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33234. /**
  33235. * Fired when the B button on this controller is modified
  33236. */
  33237. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33238. /**
  33239. * Fired when the X button on this controller is modified
  33240. */
  33241. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33242. /**
  33243. * Fired when the Y button on this controller is modified
  33244. */
  33245. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33246. /**
  33247. * Called once for each button that changed state since the last frame
  33248. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  33249. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  33250. * 2) secondary trigger (same)
  33251. * 3) A (right) X (left), touch, pressed = value
  33252. * 4) B / Y
  33253. * 5) thumb rest
  33254. * @param buttonIdx Which button index changed
  33255. * @param state New state of the button
  33256. * @param changes Which properties on the state changed since last frame
  33257. */
  33258. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33259. }
  33260. }
  33261. declare module BABYLON {
  33262. /**
  33263. * Defines the types of pose enabled controllers that are supported
  33264. */
  33265. enum PoseEnabledControllerType {
  33266. /**
  33267. * HTC Vive
  33268. */
  33269. VIVE = 0,
  33270. /**
  33271. * Oculus Rift
  33272. */
  33273. OCULUS = 1,
  33274. /**
  33275. * Windows mixed reality
  33276. */
  33277. WINDOWS = 2,
  33278. /**
  33279. * Samsung gear VR
  33280. */
  33281. GEAR_VR = 3,
  33282. /**
  33283. * Google Daydream
  33284. */
  33285. DAYDREAM = 4,
  33286. /**
  33287. * Generic
  33288. */
  33289. GENERIC = 5
  33290. }
  33291. /**
  33292. * Defines the MutableGamepadButton interface for the state of a gamepad button
  33293. */
  33294. interface MutableGamepadButton {
  33295. /**
  33296. * Value of the button/trigger
  33297. */
  33298. value: number;
  33299. /**
  33300. * If the button/trigger is currently touched
  33301. */
  33302. touched: boolean;
  33303. /**
  33304. * If the button/trigger is currently pressed
  33305. */
  33306. pressed: boolean;
  33307. }
  33308. /**
  33309. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  33310. * @hidden
  33311. */
  33312. interface ExtendedGamepadButton extends GamepadButton {
  33313. /**
  33314. * If the button/trigger is currently pressed
  33315. */
  33316. readonly pressed: boolean;
  33317. /**
  33318. * If the button/trigger is currently touched
  33319. */
  33320. readonly touched: boolean;
  33321. /**
  33322. * Value of the button/trigger
  33323. */
  33324. readonly value: number;
  33325. }
  33326. /**
  33327. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33328. */
  33329. class PoseEnabledControllerHelper {
  33330. /**
  33331. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33332. * @param vrGamepad the gamepad to initialized
  33333. * @returns a vr controller of the type the gamepad identified as
  33334. */
  33335. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  33336. }
  33337. /**
  33338. * Defines the PoseEnabledController object that contains state of a vr capable controller
  33339. */
  33340. class PoseEnabledController extends Gamepad implements PoseControlled {
  33341. private _deviceRoomPosition;
  33342. private _deviceRoomRotationQuaternion;
  33343. /**
  33344. * The device position in babylon space
  33345. */
  33346. devicePosition: Vector3;
  33347. /**
  33348. * The device rotation in babylon space
  33349. */
  33350. deviceRotationQuaternion: Quaternion;
  33351. /**
  33352. * The scale factor of the device in babylon space
  33353. */
  33354. deviceScaleFactor: number;
  33355. /**
  33356. * (Likely devicePosition should be used instead) The device position in its room space
  33357. */
  33358. position: Vector3;
  33359. /**
  33360. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  33361. */
  33362. rotationQuaternion: Quaternion;
  33363. /**
  33364. * The type of controller (Eg. Windows mixed reality)
  33365. */
  33366. controllerType: PoseEnabledControllerType;
  33367. protected _calculatedPosition: Vector3;
  33368. private _calculatedRotation;
  33369. /**
  33370. * The raw pose from the device
  33371. */
  33372. rawPose: DevicePose;
  33373. /**
  33374. * Internal, the mesh attached to the controller
  33375. */
  33376. _mesh: Nullable<AbstractMesh>;
  33377. private _poseControlledCamera;
  33378. private _leftHandSystemQuaternion;
  33379. /**
  33380. * Internal, matrix used to convert room space to babylon space
  33381. */
  33382. _deviceToWorld: Matrix;
  33383. /**
  33384. * Node to be used when casting a ray from the controller
  33385. */
  33386. _pointingPoseNode: Nullable<AbstractMesh>;
  33387. /**
  33388. * Name of the child mesh that can be used to cast a ray from the controller
  33389. */
  33390. static readonly POINTING_POSE: string;
  33391. /**
  33392. * Creates a new PoseEnabledController from a gamepad
  33393. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  33394. */
  33395. constructor(browserGamepad: any);
  33396. private _workingMatrix;
  33397. /**
  33398. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  33399. */
  33400. update(): void;
  33401. /**
  33402. * Updates only the pose device and mesh without doing any button event checking
  33403. */
  33404. protected _updatePoseAndMesh(): void;
  33405. /**
  33406. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  33407. * @param poseData raw pose fromthe device
  33408. */
  33409. updateFromDevice(poseData: DevicePose): void;
  33410. /**
  33411. * @hidden
  33412. */
  33413. _meshAttachedObservable: Observable<AbstractMesh>;
  33414. /**
  33415. * Attaches a mesh to the controller
  33416. * @param mesh the mesh to be attached
  33417. */
  33418. attachToMesh(mesh: AbstractMesh): void;
  33419. /**
  33420. * Attaches the controllers mesh to a camera
  33421. * @param camera the camera the mesh should be attached to
  33422. */
  33423. attachToPoseControlledCamera(camera: TargetCamera): void;
  33424. /**
  33425. * Disposes of the controller
  33426. */
  33427. dispose(): void;
  33428. /**
  33429. * The mesh that is attached to the controller
  33430. */
  33431. readonly mesh: Nullable<AbstractMesh>;
  33432. /**
  33433. * Gets the ray of the controller in the direction the controller is pointing
  33434. * @param length the length the resulting ray should be
  33435. * @returns a ray in the direction the controller is pointing
  33436. */
  33437. getForwardRay(length?: number): Ray;
  33438. }
  33439. }
  33440. declare module BABYLON {
  33441. /**
  33442. * Vive Controller
  33443. */
  33444. class ViveController extends WebVRController {
  33445. /**
  33446. * Base Url for the controller model.
  33447. */
  33448. static MODEL_BASE_URL: string;
  33449. /**
  33450. * File name for the controller model.
  33451. */
  33452. static MODEL_FILENAME: string;
  33453. /**
  33454. * Creates a new ViveController from a gamepad
  33455. * @param vrGamepad the gamepad that the controller should be created from
  33456. */
  33457. constructor(vrGamepad: any);
  33458. /**
  33459. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33460. * @param scene scene in which to add meshes
  33461. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33462. */
  33463. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33464. /**
  33465. * Fired when the left button on this controller is modified
  33466. */
  33467. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33468. /**
  33469. * Fired when the right button on this controller is modified
  33470. */
  33471. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33472. /**
  33473. * Fired when the menu button on this controller is modified
  33474. */
  33475. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33476. /**
  33477. * Called once for each button that changed state since the last frame
  33478. * Vive mapping:
  33479. * 0: touchpad
  33480. * 1: trigger
  33481. * 2: left AND right buttons
  33482. * 3: menu button
  33483. * @param buttonIdx Which button index changed
  33484. * @param state New state of the button
  33485. * @param changes Which properties on the state changed since last frame
  33486. */
  33487. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33488. }
  33489. }
  33490. declare module BABYLON {
  33491. /**
  33492. * Defines the WebVRController object that represents controllers tracked in 3D space
  33493. */
  33494. abstract class WebVRController extends PoseEnabledController {
  33495. /**
  33496. * Internal, the default controller model for the controller
  33497. */
  33498. protected _defaultModel: AbstractMesh;
  33499. /**
  33500. * Fired when the trigger state has changed
  33501. */
  33502. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  33503. /**
  33504. * Fired when the main button state has changed
  33505. */
  33506. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33507. /**
  33508. * Fired when the secondary button state has changed
  33509. */
  33510. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33511. /**
  33512. * Fired when the pad state has changed
  33513. */
  33514. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  33515. /**
  33516. * Fired when controllers stick values have changed
  33517. */
  33518. onPadValuesChangedObservable: Observable<StickValues>;
  33519. /**
  33520. * Array of button availible on the controller
  33521. */
  33522. protected _buttons: Array<MutableGamepadButton>;
  33523. private _onButtonStateChange;
  33524. /**
  33525. * Fired when a controller button's state has changed
  33526. * @param callback the callback containing the button that was modified
  33527. */
  33528. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  33529. /**
  33530. * X and Y axis corrisponding to the controllers joystick
  33531. */
  33532. pad: StickValues;
  33533. /**
  33534. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  33535. */
  33536. hand: string;
  33537. /**
  33538. * The default controller model for the controller
  33539. */
  33540. readonly defaultModel: AbstractMesh;
  33541. /**
  33542. * Creates a new WebVRController from a gamepad
  33543. * @param vrGamepad the gamepad that the WebVRController should be created from
  33544. */
  33545. constructor(vrGamepad: any);
  33546. /**
  33547. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  33548. */
  33549. update(): void;
  33550. /**
  33551. * Function to be called when a button is modified
  33552. */
  33553. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33554. /**
  33555. * Loads a mesh and attaches it to the controller
  33556. * @param scene the scene the mesh should be added to
  33557. * @param meshLoaded callback for when the mesh has been loaded
  33558. */
  33559. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33560. private _setButtonValue;
  33561. private _changes;
  33562. private _checkChanges;
  33563. /**
  33564. * Disposes of th webVRCOntroller
  33565. */
  33566. dispose(): void;
  33567. }
  33568. }
  33569. declare module BABYLON {
  33570. /**
  33571. * Defines the WindowsMotionController object that the state of the windows motion controller
  33572. */
  33573. class WindowsMotionController extends WebVRController {
  33574. /**
  33575. * The base url used to load the left and right controller models
  33576. */
  33577. static MODEL_BASE_URL: string;
  33578. /**
  33579. * The name of the left controller model file
  33580. */
  33581. static MODEL_LEFT_FILENAME: string;
  33582. /**
  33583. * The name of the right controller model file
  33584. */
  33585. static MODEL_RIGHT_FILENAME: string;
  33586. /**
  33587. * The controller name prefix for this controller type
  33588. */
  33589. static readonly GAMEPAD_ID_PREFIX: string;
  33590. /**
  33591. * The controller id pattern for this controller type
  33592. */
  33593. private static readonly GAMEPAD_ID_PATTERN;
  33594. private _loadedMeshInfo;
  33595. private readonly _mapping;
  33596. /**
  33597. * Fired when the trackpad on this controller is clicked
  33598. */
  33599. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  33600. /**
  33601. * Fired when the trackpad on this controller is modified
  33602. */
  33603. onTrackpadValuesChangedObservable: Observable<StickValues>;
  33604. /**
  33605. * The current x and y values of this controller's trackpad
  33606. */
  33607. trackpad: StickValues;
  33608. /**
  33609. * Creates a new WindowsMotionController from a gamepad
  33610. * @param vrGamepad the gamepad that the controller should be created from
  33611. */
  33612. constructor(vrGamepad: any);
  33613. /**
  33614. * Fired when the trigger on this controller is modified
  33615. */
  33616. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33617. /**
  33618. * Fired when the menu button on this controller is modified
  33619. */
  33620. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33621. /**
  33622. * Fired when the grip button on this controller is modified
  33623. */
  33624. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33625. /**
  33626. * Fired when the thumbstick button on this controller is modified
  33627. */
  33628. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33629. /**
  33630. * Fired when the touchpad button on this controller is modified
  33631. */
  33632. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33633. /**
  33634. * Fired when the touchpad values on this controller are modified
  33635. */
  33636. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  33637. private _updateTrackpad;
  33638. /**
  33639. * Called once per frame by the engine.
  33640. */
  33641. update(): void;
  33642. /**
  33643. * Called once for each button that changed state since the last frame
  33644. * @param buttonIdx Which button index changed
  33645. * @param state New state of the button
  33646. * @param changes Which properties on the state changed since last frame
  33647. */
  33648. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33649. /**
  33650. * Moves the buttons on the controller mesh based on their current state
  33651. * @param buttonName the name of the button to move
  33652. * @param buttonValue the value of the button which determines the buttons new position
  33653. */
  33654. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  33655. /**
  33656. * Moves the axis on the controller mesh based on its current state
  33657. * @param axis the index of the axis
  33658. * @param axisValue the value of the axis which determines the meshes new position
  33659. * @hidden
  33660. */
  33661. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  33662. /**
  33663. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33664. * @param scene scene in which to add meshes
  33665. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33666. */
  33667. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  33668. /**
  33669. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  33670. * can be transformed by button presses and axes values, based on this._mapping.
  33671. *
  33672. * @param scene scene in which the meshes exist
  33673. * @param meshes list of meshes that make up the controller model to process
  33674. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  33675. */
  33676. private processModel;
  33677. private createMeshInfo;
  33678. /**
  33679. * Gets the ray of the controller in the direction the controller is pointing
  33680. * @param length the length the resulting ray should be
  33681. * @returns a ray in the direction the controller is pointing
  33682. */
  33683. getForwardRay(length?: number): Ray;
  33684. /**
  33685. * Disposes of the controller
  33686. */
  33687. dispose(): void;
  33688. }
  33689. }
  33690. declare module BABYLON {
  33691. }
  33692. declare module BABYLON {
  33693. /**
  33694. * Interface to implement to create a shadow generator compatible with BJS.
  33695. */
  33696. interface IShadowGenerator {
  33697. /**
  33698. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33699. * @returns The render target texture if present otherwise, null
  33700. */
  33701. getShadowMap(): Nullable<RenderTargetTexture>;
  33702. /**
  33703. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33704. * @returns The render target texture if the shadow map is present otherwise, null
  33705. */
  33706. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33707. /**
  33708. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33709. * @param subMesh The submesh we want to render in the shadow map
  33710. * @param useInstances Defines wether will draw in the map using instances
  33711. * @returns true if ready otherwise, false
  33712. */
  33713. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33714. /**
  33715. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33716. * @param defines Defines of the material we want to update
  33717. * @param lightIndex Index of the light in the enabled light list of the material
  33718. */
  33719. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  33720. /**
  33721. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33722. * defined in the generator but impacting the effect).
  33723. * It implies the unifroms available on the materials are the standard BJS ones.
  33724. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33725. * @param effect The effect we are binfing the information for
  33726. */
  33727. bindShadowLight(lightIndex: string, effect: Effect): void;
  33728. /**
  33729. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33730. * (eq to shadow prjection matrix * light transform matrix)
  33731. * @returns The transform matrix used to create the shadow map
  33732. */
  33733. getTransformMatrix(): Matrix;
  33734. /**
  33735. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33736. * Cube and 2D textures for instance.
  33737. */
  33738. recreateShadowMap(): void;
  33739. /**
  33740. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33741. * @param onCompiled Callback triggered at the and of the effects compilation
  33742. * @param options Sets of optional options forcing the compilation with different modes
  33743. */
  33744. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33745. useInstances: boolean;
  33746. }>): void;
  33747. /**
  33748. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33749. * @param options Sets of optional options forcing the compilation with different modes
  33750. * @returns A promise that resolves when the compilation completes
  33751. */
  33752. forceCompilationAsync(options?: Partial<{
  33753. useInstances: boolean;
  33754. }>): Promise<void>;
  33755. /**
  33756. * Serializes the shadow generator setup to a json object.
  33757. * @returns The serialized JSON object
  33758. */
  33759. serialize(): any;
  33760. /**
  33761. * Disposes the Shadow map and related Textures and effects.
  33762. */
  33763. dispose(): void;
  33764. }
  33765. /**
  33766. * Default implementation IShadowGenerator.
  33767. * This is the main object responsible of generating shadows in the framework.
  33768. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  33769. */
  33770. class ShadowGenerator implements IShadowGenerator {
  33771. /**
  33772. * Shadow generator mode None: no filtering applied.
  33773. */
  33774. static readonly FILTER_NONE: number;
  33775. /**
  33776. * Shadow generator mode ESM: Exponential Shadow Mapping.
  33777. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33778. */
  33779. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  33780. /**
  33781. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  33782. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  33783. */
  33784. static readonly FILTER_POISSONSAMPLING: number;
  33785. /**
  33786. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  33787. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33788. */
  33789. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  33790. /**
  33791. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  33792. * edge artifacts on steep falloff.
  33793. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33794. */
  33795. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  33796. /**
  33797. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  33798. * edge artifacts on steep falloff.
  33799. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33800. */
  33801. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  33802. /**
  33803. * Shadow generator mode PCF: Percentage Closer Filtering
  33804. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  33805. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  33806. */
  33807. static readonly FILTER_PCF: number;
  33808. /**
  33809. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  33810. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  33811. * Contact Hardening
  33812. */
  33813. static readonly FILTER_PCSS: number;
  33814. /**
  33815. * Reserved for PCF and PCSS
  33816. * Highest Quality.
  33817. *
  33818. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  33819. *
  33820. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  33821. */
  33822. static readonly QUALITY_HIGH: number;
  33823. /**
  33824. * Reserved for PCF and PCSS
  33825. * Good tradeoff for quality/perf cross devices
  33826. *
  33827. * Execute PCF on a 3*3 kernel.
  33828. *
  33829. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  33830. */
  33831. static readonly QUALITY_MEDIUM: number;
  33832. /**
  33833. * Reserved for PCF and PCSS
  33834. * The lowest quality but the fastest.
  33835. *
  33836. * Execute PCF on a 1*1 kernel.
  33837. *
  33838. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  33839. */
  33840. static readonly QUALITY_LOW: number;
  33841. private _bias;
  33842. /**
  33843. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  33844. */
  33845. /**
  33846. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  33847. */
  33848. bias: number;
  33849. private _normalBias;
  33850. /**
  33851. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  33852. */
  33853. /**
  33854. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  33855. */
  33856. normalBias: number;
  33857. private _blurBoxOffset;
  33858. /**
  33859. * Gets the blur box offset: offset applied during the blur pass.
  33860. * Only usefull if useKernelBlur = false
  33861. */
  33862. /**
  33863. * Sets the blur box offset: offset applied during the blur pass.
  33864. * Only usefull if useKernelBlur = false
  33865. */
  33866. blurBoxOffset: number;
  33867. private _blurScale;
  33868. /**
  33869. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  33870. * 2 means half of the size.
  33871. */
  33872. /**
  33873. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  33874. * 2 means half of the size.
  33875. */
  33876. blurScale: number;
  33877. private _blurKernel;
  33878. /**
  33879. * Gets the blur kernel: kernel size of the blur pass.
  33880. * Only usefull if useKernelBlur = true
  33881. */
  33882. /**
  33883. * Sets the blur kernel: kernel size of the blur pass.
  33884. * Only usefull if useKernelBlur = true
  33885. */
  33886. blurKernel: number;
  33887. private _useKernelBlur;
  33888. /**
  33889. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  33890. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33891. */
  33892. /**
  33893. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  33894. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33895. */
  33896. useKernelBlur: boolean;
  33897. private _depthScale;
  33898. /**
  33899. * Gets the depth scale used in ESM mode.
  33900. */
  33901. /**
  33902. * Sets the depth scale used in ESM mode.
  33903. * This can override the scale stored on the light.
  33904. */
  33905. depthScale: number;
  33906. private _filter;
  33907. /**
  33908. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  33909. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33910. */
  33911. /**
  33912. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  33913. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33914. */
  33915. filter: number;
  33916. /**
  33917. * Gets if the current filter is set to Poisson Sampling.
  33918. */
  33919. /**
  33920. * Sets the current filter to Poisson Sampling.
  33921. */
  33922. usePoissonSampling: boolean;
  33923. /**
  33924. * Gets if the current filter is set to VSM.
  33925. * DEPRECATED. Should use useExponentialShadowMap instead.
  33926. */
  33927. /**
  33928. * Sets the current filter is to VSM.
  33929. * DEPRECATED. Should use useExponentialShadowMap instead.
  33930. */
  33931. useVarianceShadowMap: boolean;
  33932. /**
  33933. * Gets if the current filter is set to blurred VSM.
  33934. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33935. */
  33936. /**
  33937. * Sets the current filter is to blurred VSM.
  33938. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33939. */
  33940. useBlurVarianceShadowMap: boolean;
  33941. /**
  33942. * Gets if the current filter is set to ESM.
  33943. */
  33944. /**
  33945. * Sets the current filter is to ESM.
  33946. */
  33947. useExponentialShadowMap: boolean;
  33948. /**
  33949. * Gets if the current filter is set to filtered ESM.
  33950. */
  33951. /**
  33952. * Gets if the current filter is set to filtered ESM.
  33953. */
  33954. useBlurExponentialShadowMap: boolean;
  33955. /**
  33956. * Gets if the current filter is set to "close ESM" (using the inverse of the
  33957. * exponential to prevent steep falloff artifacts).
  33958. */
  33959. /**
  33960. * Sets the current filter to "close ESM" (using the inverse of the
  33961. * exponential to prevent steep falloff artifacts).
  33962. */
  33963. useCloseExponentialShadowMap: boolean;
  33964. /**
  33965. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  33966. * exponential to prevent steep falloff artifacts).
  33967. */
  33968. /**
  33969. * Sets the current filter to filtered "close ESM" (using the inverse of the
  33970. * exponential to prevent steep falloff artifacts).
  33971. */
  33972. useBlurCloseExponentialShadowMap: boolean;
  33973. /**
  33974. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  33975. */
  33976. /**
  33977. * Sets the current filter to "PCF" (percentage closer filtering).
  33978. */
  33979. usePercentageCloserFiltering: boolean;
  33980. private _filteringQuality;
  33981. /**
  33982. * Gets the PCF or PCSS Quality.
  33983. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33984. */
  33985. /**
  33986. * Sets the PCF or PCSS Quality.
  33987. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33988. */
  33989. filteringQuality: number;
  33990. /**
  33991. * Gets if the current filter is set to "PCSS" (contact hardening).
  33992. */
  33993. /**
  33994. * Sets the current filter to "PCSS" (contact hardening).
  33995. */
  33996. useContactHardeningShadow: boolean;
  33997. private _contactHardeningLightSizeUVRatio;
  33998. /**
  33999. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34000. * Using a ratio helps keeping shape stability independently of the map size.
  34001. *
  34002. * It does not account for the light projection as it was having too much
  34003. * instability during the light setup or during light position changes.
  34004. *
  34005. * Only valid if useContactHardeningShadow is true.
  34006. */
  34007. /**
  34008. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34009. * Using a ratio helps keeping shape stability independently of the map size.
  34010. *
  34011. * It does not account for the light projection as it was having too much
  34012. * instability during the light setup or during light position changes.
  34013. *
  34014. * Only valid if useContactHardeningShadow is true.
  34015. */
  34016. contactHardeningLightSizeUVRatio: number;
  34017. private _darkness;
  34018. /**
  34019. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  34020. * 0 means strongest and 1 would means no shadow.
  34021. * @returns the darkness.
  34022. */
  34023. getDarkness(): number;
  34024. /**
  34025. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  34026. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  34027. * @returns the shadow generator allowing fluent coding.
  34028. */
  34029. setDarkness(darkness: number): ShadowGenerator;
  34030. private _transparencyShadow;
  34031. /**
  34032. * Sets the ability to have transparent shadow (boolean).
  34033. * @param transparent True if transparent else False
  34034. * @returns the shadow generator allowing fluent coding
  34035. */
  34036. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  34037. private _shadowMap;
  34038. private _shadowMap2;
  34039. /**
  34040. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34041. * @returns The render target texture if present otherwise, null
  34042. */
  34043. getShadowMap(): Nullable<RenderTargetTexture>;
  34044. /**
  34045. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34046. * @returns The render target texture if the shadow map is present otherwise, null
  34047. */
  34048. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34049. /**
  34050. * Helper function to add a mesh and its descendants to the list of shadow casters.
  34051. * @param mesh Mesh to add
  34052. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  34053. * @returns the Shadow Generator itself
  34054. */
  34055. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34056. /**
  34057. * Helper function to remove a mesh and its descendants from the list of shadow casters
  34058. * @param mesh Mesh to remove
  34059. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  34060. * @returns the Shadow Generator itself
  34061. */
  34062. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34063. /**
  34064. * Controls the extent to which the shadows fade out at the edge of the frustum
  34065. * Used only by directionals and spots
  34066. */
  34067. frustumEdgeFalloff: number;
  34068. private _light;
  34069. /**
  34070. * Returns the associated light object.
  34071. * @returns the light generating the shadow
  34072. */
  34073. getLight(): IShadowLight;
  34074. /**
  34075. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  34076. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  34077. * It might on the other hand introduce peter panning.
  34078. */
  34079. forceBackFacesOnly: boolean;
  34080. private _scene;
  34081. private _lightDirection;
  34082. private _effect;
  34083. private _viewMatrix;
  34084. private _projectionMatrix;
  34085. private _transformMatrix;
  34086. private _cachedPosition;
  34087. private _cachedDirection;
  34088. private _cachedDefines;
  34089. private _currentRenderID;
  34090. private _boxBlurPostprocess;
  34091. private _kernelBlurXPostprocess;
  34092. private _kernelBlurYPostprocess;
  34093. private _blurPostProcesses;
  34094. private _mapSize;
  34095. private _currentFaceIndex;
  34096. private _currentFaceIndexCache;
  34097. private _textureType;
  34098. private _defaultTextureMatrix;
  34099. /**
  34100. * Creates a ShadowGenerator object.
  34101. * A ShadowGenerator is the required tool to use the shadows.
  34102. * Each light casting shadows needs to use its own ShadowGenerator.
  34103. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  34104. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  34105. * @param light The light object generating the shadows.
  34106. * @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.
  34107. */
  34108. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  34109. private _initializeGenerator;
  34110. private _initializeShadowMap;
  34111. private _initializeBlurRTTAndPostProcesses;
  34112. private _renderForShadowMap;
  34113. private _renderSubMeshForShadowMap;
  34114. private _applyFilterValues;
  34115. /**
  34116. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34117. * @param onCompiled Callback triggered at the and of the effects compilation
  34118. * @param options Sets of optional options forcing the compilation with different modes
  34119. */
  34120. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34121. useInstances: boolean;
  34122. }>): void;
  34123. /**
  34124. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34125. * @param options Sets of optional options forcing the compilation with different modes
  34126. * @returns A promise that resolves when the compilation completes
  34127. */
  34128. forceCompilationAsync(options?: Partial<{
  34129. useInstances: boolean;
  34130. }>): Promise<void>;
  34131. /**
  34132. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34133. * @param subMesh The submesh we want to render in the shadow map
  34134. * @param useInstances Defines wether will draw in the map using instances
  34135. * @returns true if ready otherwise, false
  34136. */
  34137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34138. /**
  34139. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34140. * @param defines Defines of the material we want to update
  34141. * @param lightIndex Index of the light in the enabled light list of the material
  34142. */
  34143. prepareDefines(defines: any, lightIndex: number): void;
  34144. /**
  34145. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34146. * defined in the generator but impacting the effect).
  34147. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34148. * @param effect The effect we are binfing the information for
  34149. */
  34150. bindShadowLight(lightIndex: string, effect: Effect): void;
  34151. /**
  34152. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34153. * (eq to shadow prjection matrix * light transform matrix)
  34154. * @returns The transform matrix used to create the shadow map
  34155. */
  34156. getTransformMatrix(): Matrix;
  34157. /**
  34158. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34159. * Cube and 2D textures for instance.
  34160. */
  34161. recreateShadowMap(): void;
  34162. private _disposeBlurPostProcesses;
  34163. private _disposeRTTandPostProcesses;
  34164. /**
  34165. * Disposes the ShadowGenerator.
  34166. * Returns nothing.
  34167. */
  34168. dispose(): void;
  34169. /**
  34170. * Serializes the shadow generator setup to a json object.
  34171. * @returns The serialized JSON object
  34172. */
  34173. serialize(): any;
  34174. /**
  34175. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  34176. * @param parsedShadowGenerator The JSON object to parse
  34177. * @param scene The scene to create the shadow map for
  34178. * @returns The parsed shadow generator
  34179. */
  34180. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  34181. }
  34182. }
  34183. declare module BABYLON {
  34184. /**
  34185. * Background material used to create an efficient environement around your scene.
  34186. */
  34187. class BackgroundMaterial extends PushMaterial {
  34188. /**
  34189. * Standard reflectance value at parallel view angle.
  34190. */
  34191. static StandardReflectance0: number;
  34192. /**
  34193. * Standard reflectance value at grazing angle.
  34194. */
  34195. static StandardReflectance90: number;
  34196. protected _primaryColor: Color3;
  34197. /**
  34198. * Key light Color (multiply against the environement texture)
  34199. */
  34200. primaryColor: Color3;
  34201. protected __perceptualColor: Nullable<Color3>;
  34202. /**
  34203. * Experimental Internal Use Only.
  34204. *
  34205. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  34206. * This acts as a helper to set the primary color to a more "human friendly" value.
  34207. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  34208. * output color as close as possible from the chosen value.
  34209. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  34210. * part of lighting setup.)
  34211. */
  34212. _perceptualColor: Nullable<Color3>;
  34213. protected _primaryColorShadowLevel: float;
  34214. /**
  34215. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  34216. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  34217. */
  34218. primaryColorShadowLevel: float;
  34219. protected _primaryColorHighlightLevel: float;
  34220. /**
  34221. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  34222. * The primary color is used at the level chosen to define what the white area would look.
  34223. */
  34224. primaryColorHighlightLevel: float;
  34225. protected _reflectionTexture: Nullable<BaseTexture>;
  34226. /**
  34227. * Reflection Texture used in the material.
  34228. * Should be author in a specific way for the best result (refer to the documentation).
  34229. */
  34230. reflectionTexture: Nullable<BaseTexture>;
  34231. protected _reflectionBlur: float;
  34232. /**
  34233. * Reflection Texture level of blur.
  34234. *
  34235. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  34236. * texture twice.
  34237. */
  34238. reflectionBlur: float;
  34239. protected _diffuseTexture: Nullable<BaseTexture>;
  34240. /**
  34241. * Diffuse Texture used in the material.
  34242. * Should be author in a specific way for the best result (refer to the documentation).
  34243. */
  34244. diffuseTexture: Nullable<BaseTexture>;
  34245. protected _shadowLights: Nullable<IShadowLight[]>;
  34246. /**
  34247. * Specify the list of lights casting shadow on the material.
  34248. * All scene shadow lights will be included if null.
  34249. */
  34250. shadowLights: Nullable<IShadowLight[]>;
  34251. protected _shadowLevel: float;
  34252. /**
  34253. * Helps adjusting the shadow to a softer level if required.
  34254. * 0 means black shadows and 1 means no shadows.
  34255. */
  34256. shadowLevel: float;
  34257. protected _sceneCenter: Vector3;
  34258. /**
  34259. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  34260. * It is usually zero but might be interesting to modify according to your setup.
  34261. */
  34262. sceneCenter: Vector3;
  34263. protected _opacityFresnel: boolean;
  34264. /**
  34265. * This helps specifying that the material is falling off to the sky box at grazing angle.
  34266. * This helps ensuring a nice transition when the camera goes under the ground.
  34267. */
  34268. opacityFresnel: boolean;
  34269. protected _reflectionFresnel: boolean;
  34270. /**
  34271. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  34272. * This helps adding a mirror texture on the ground.
  34273. */
  34274. reflectionFresnel: boolean;
  34275. protected _reflectionFalloffDistance: number;
  34276. /**
  34277. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  34278. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  34279. */
  34280. reflectionFalloffDistance: number;
  34281. protected _reflectionAmount: number;
  34282. /**
  34283. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  34284. */
  34285. reflectionAmount: number;
  34286. protected _reflectionReflectance0: number;
  34287. /**
  34288. * This specifies the weight of the reflection at grazing angle.
  34289. */
  34290. reflectionReflectance0: number;
  34291. protected _reflectionReflectance90: number;
  34292. /**
  34293. * This specifies the weight of the reflection at a perpendicular point of view.
  34294. */
  34295. reflectionReflectance90: number;
  34296. /**
  34297. * Sets the reflection reflectance fresnel values according to the default standard
  34298. * empirically know to work well :-)
  34299. */
  34300. reflectionStandardFresnelWeight: number;
  34301. protected _useRGBColor: boolean;
  34302. /**
  34303. * Helps to directly use the maps channels instead of their level.
  34304. */
  34305. useRGBColor: boolean;
  34306. protected _enableNoise: boolean;
  34307. /**
  34308. * This helps reducing the banding effect that could occur on the background.
  34309. */
  34310. enableNoise: boolean;
  34311. /**
  34312. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  34313. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  34314. * Recommended to be keep at 1.0 except for special cases.
  34315. */
  34316. fovMultiplier: number;
  34317. private _fovMultiplier;
  34318. /**
  34319. * Enable the FOV adjustment feature controlled by fovMultiplier.
  34320. */
  34321. useEquirectangularFOV: boolean;
  34322. private _maxSimultaneousLights;
  34323. /**
  34324. * Number of Simultaneous lights allowed on the material.
  34325. */
  34326. maxSimultaneousLights: int;
  34327. /**
  34328. * Default configuration related to image processing available in the Background Material.
  34329. */
  34330. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34331. /**
  34332. * Keep track of the image processing observer to allow dispose and replace.
  34333. */
  34334. private _imageProcessingObserver;
  34335. /**
  34336. * Attaches a new image processing configuration to the PBR Material.
  34337. * @param configuration (if null the scene configuration will be use)
  34338. */
  34339. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34340. /**
  34341. * Gets the image processing configuration used either in this material.
  34342. */
  34343. /**
  34344. * Sets the Default image processing configuration used either in the this material.
  34345. *
  34346. * If sets to null, the scene one is in use.
  34347. */
  34348. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  34349. /**
  34350. * Gets wether the color curves effect is enabled.
  34351. */
  34352. /**
  34353. * Sets wether the color curves effect is enabled.
  34354. */
  34355. cameraColorCurvesEnabled: boolean;
  34356. /**
  34357. * Gets wether the color grading effect is enabled.
  34358. */
  34359. /**
  34360. * Gets wether the color grading effect is enabled.
  34361. */
  34362. cameraColorGradingEnabled: boolean;
  34363. /**
  34364. * Gets wether tonemapping is enabled or not.
  34365. */
  34366. /**
  34367. * Sets wether tonemapping is enabled or not
  34368. */
  34369. cameraToneMappingEnabled: boolean;
  34370. /**
  34371. * The camera exposure used on this material.
  34372. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34373. * This corresponds to a photographic exposure.
  34374. */
  34375. /**
  34376. * The camera exposure used on this material.
  34377. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34378. * This corresponds to a photographic exposure.
  34379. */
  34380. cameraExposure: float;
  34381. /**
  34382. * Gets The camera contrast used on this material.
  34383. */
  34384. /**
  34385. * Sets The camera contrast used on this material.
  34386. */
  34387. cameraContrast: float;
  34388. /**
  34389. * Gets the Color Grading 2D Lookup Texture.
  34390. */
  34391. /**
  34392. * Sets the Color Grading 2D Lookup Texture.
  34393. */
  34394. cameraColorGradingTexture: Nullable<BaseTexture>;
  34395. /**
  34396. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34397. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34398. * 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;
  34399. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34400. */
  34401. /**
  34402. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34403. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34404. * 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;
  34405. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34406. */
  34407. cameraColorCurves: Nullable<ColorCurves>;
  34408. /**
  34409. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  34410. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  34411. */
  34412. switchToBGR: boolean;
  34413. private _renderTargets;
  34414. private _reflectionControls;
  34415. private _white;
  34416. private _primaryShadowColor;
  34417. private _primaryHighlightColor;
  34418. /**
  34419. * Instantiates a Background Material in the given scene
  34420. * @param name The friendly name of the material
  34421. * @param scene The scene to add the material to
  34422. */
  34423. constructor(name: string, scene: Scene);
  34424. /**
  34425. * The entire material has been created in order to prevent overdraw.
  34426. * @returns false
  34427. */
  34428. needAlphaTesting(): boolean;
  34429. /**
  34430. * The entire material has been created in order to prevent overdraw.
  34431. * @returns true if blending is enable
  34432. */
  34433. needAlphaBlending(): boolean;
  34434. /**
  34435. * Checks wether the material is ready to be rendered for a given mesh.
  34436. * @param mesh The mesh to render
  34437. * @param subMesh The submesh to check against
  34438. * @param useInstances Specify wether or not the material is used with instances
  34439. * @returns true if all the dependencies are ready (Textures, Effects...)
  34440. */
  34441. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34442. /**
  34443. * Compute the primary color according to the chosen perceptual color.
  34444. */
  34445. private _computePrimaryColorFromPerceptualColor;
  34446. /**
  34447. * Compute the highlights and shadow colors according to their chosen levels.
  34448. */
  34449. private _computePrimaryColors;
  34450. /**
  34451. * Build the uniform buffer used in the material.
  34452. */
  34453. buildUniformLayout(): void;
  34454. /**
  34455. * Unbind the material.
  34456. */
  34457. unbind(): void;
  34458. /**
  34459. * Bind only the world matrix to the material.
  34460. * @param world The world matrix to bind.
  34461. */
  34462. bindOnlyWorldMatrix(world: Matrix): void;
  34463. /**
  34464. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  34465. * @param world The world matrix to bind.
  34466. * @param subMesh The submesh to bind for.
  34467. */
  34468. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34469. /**
  34470. * Dispose the material.
  34471. * @param forceDisposeEffect Force disposal of the associated effect.
  34472. * @param forceDisposeTextures Force disposal of the associated textures.
  34473. */
  34474. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34475. /**
  34476. * Clones the material.
  34477. * @param name The cloned name.
  34478. * @returns The cloned material.
  34479. */
  34480. clone(name: string): BackgroundMaterial;
  34481. /**
  34482. * Serializes the current material to its JSON representation.
  34483. * @returns The JSON representation.
  34484. */
  34485. serialize(): any;
  34486. /**
  34487. * Gets the class name of the material
  34488. * @returns "BackgroundMaterial"
  34489. */
  34490. getClassName(): string;
  34491. /**
  34492. * Parse a JSON input to create back a background material.
  34493. * @param source The JSON data to parse
  34494. * @param scene The scene to create the parsed material in
  34495. * @param rootUrl The root url of the assets the material depends upon
  34496. * @returns the instantiated BackgroundMaterial.
  34497. */
  34498. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  34499. }
  34500. }
  34501. declare module BABYLON {
  34502. /**
  34503. * The Physically based material base class of BJS.
  34504. *
  34505. * This offers the main features of a standard PBR material.
  34506. * For more information, please refer to the documentation :
  34507. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  34508. */
  34509. abstract class PBRBaseMaterial extends PushMaterial {
  34510. /**
  34511. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  34512. */
  34513. static readonly LIGHTFALLOFF_PHYSICAL: number;
  34514. /**
  34515. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  34516. * to enhance interoperability with other engines.
  34517. */
  34518. static readonly LIGHTFALLOFF_GLTF: number;
  34519. /**
  34520. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  34521. * to enhance interoperability with other materials.
  34522. */
  34523. static readonly LIGHTFALLOFF_STANDARD: number;
  34524. /**
  34525. * Intensity of the direct lights e.g. the four lights available in your scene.
  34526. * This impacts both the direct diffuse and specular highlights.
  34527. */
  34528. protected _directIntensity: number;
  34529. /**
  34530. * Intensity of the emissive part of the material.
  34531. * This helps controlling the emissive effect without modifying the emissive color.
  34532. */
  34533. protected _emissiveIntensity: number;
  34534. /**
  34535. * Intensity of the environment e.g. how much the environment will light the object
  34536. * either through harmonics for rough material or through the refelction for shiny ones.
  34537. */
  34538. protected _environmentIntensity: number;
  34539. /**
  34540. * This is a special control allowing the reduction of the specular highlights coming from the
  34541. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  34542. */
  34543. protected _specularIntensity: number;
  34544. /**
  34545. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  34546. */
  34547. private _lightingInfos;
  34548. /**
  34549. * Debug Control allowing disabling the bump map on this material.
  34550. */
  34551. protected _disableBumpMap: boolean;
  34552. /**
  34553. * AKA Diffuse Texture in standard nomenclature.
  34554. */
  34555. protected _albedoTexture: BaseTexture;
  34556. /**
  34557. * AKA Occlusion Texture in other nomenclature.
  34558. */
  34559. protected _ambientTexture: BaseTexture;
  34560. /**
  34561. * AKA Occlusion Texture Intensity in other nomenclature.
  34562. */
  34563. protected _ambientTextureStrength: number;
  34564. /**
  34565. * Stores the alpha values in a texture.
  34566. */
  34567. protected _opacityTexture: BaseTexture;
  34568. /**
  34569. * Stores the reflection values in a texture.
  34570. */
  34571. protected _reflectionTexture: BaseTexture;
  34572. /**
  34573. * Stores the refraction values in a texture.
  34574. */
  34575. protected _refractionTexture: BaseTexture;
  34576. /**
  34577. * Stores the emissive values in a texture.
  34578. */
  34579. protected _emissiveTexture: BaseTexture;
  34580. /**
  34581. * AKA Specular texture in other nomenclature.
  34582. */
  34583. protected _reflectivityTexture: BaseTexture;
  34584. /**
  34585. * Used to switch from specular/glossiness to metallic/roughness workflow.
  34586. */
  34587. protected _metallicTexture: BaseTexture;
  34588. /**
  34589. * Specifies the metallic scalar of the metallic/roughness workflow.
  34590. * Can also be used to scale the metalness values of the metallic texture.
  34591. */
  34592. protected _metallic: Nullable<number>;
  34593. /**
  34594. * Specifies the roughness scalar of the metallic/roughness workflow.
  34595. * Can also be used to scale the roughness values of the metallic texture.
  34596. */
  34597. protected _roughness: Nullable<number>;
  34598. /**
  34599. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  34600. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  34601. */
  34602. protected _microSurfaceTexture: BaseTexture;
  34603. /**
  34604. * Stores surface normal data used to displace a mesh in a texture.
  34605. */
  34606. protected _bumpTexture: BaseTexture;
  34607. /**
  34608. * Stores the pre-calculated light information of a mesh in a texture.
  34609. */
  34610. protected _lightmapTexture: BaseTexture;
  34611. /**
  34612. * The color of a material in ambient lighting.
  34613. */
  34614. protected _ambientColor: Color3;
  34615. /**
  34616. * AKA Diffuse Color in other nomenclature.
  34617. */
  34618. protected _albedoColor: Color3;
  34619. /**
  34620. * AKA Specular Color in other nomenclature.
  34621. */
  34622. protected _reflectivityColor: Color3;
  34623. /**
  34624. * The color applied when light is reflected from a material.
  34625. */
  34626. protected _reflectionColor: Color3;
  34627. /**
  34628. * The color applied when light is emitted from a material.
  34629. */
  34630. protected _emissiveColor: Color3;
  34631. /**
  34632. * AKA Glossiness in other nomenclature.
  34633. */
  34634. protected _microSurface: number;
  34635. /**
  34636. * source material index of refraction (IOR)' / 'destination material IOR.
  34637. */
  34638. protected _indexOfRefraction: number;
  34639. /**
  34640. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  34641. */
  34642. protected _invertRefractionY: boolean;
  34643. /**
  34644. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  34645. * Materials half opaque for instance using refraction could benefit from this control.
  34646. */
  34647. protected _linkRefractionWithTransparency: boolean;
  34648. /**
  34649. * Specifies that the material will use the light map as a show map.
  34650. */
  34651. protected _useLightmapAsShadowmap: boolean;
  34652. /**
  34653. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  34654. * makes the reflect vector face the model (under horizon).
  34655. */
  34656. protected _useHorizonOcclusion: boolean;
  34657. /**
  34658. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34659. * too much the area relying on ambient texture to define their ambient occlusion.
  34660. */
  34661. protected _useRadianceOcclusion: boolean;
  34662. /**
  34663. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34664. */
  34665. protected _useAlphaFromAlbedoTexture: boolean;
  34666. /**
  34667. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34668. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34669. */
  34670. protected _useSpecularOverAlpha: boolean;
  34671. /**
  34672. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34673. */
  34674. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34675. /**
  34676. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34677. */
  34678. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  34679. /**
  34680. * Specifies if the metallic texture contains the roughness information in its green channel.
  34681. */
  34682. protected _useRoughnessFromMetallicTextureGreen: boolean;
  34683. /**
  34684. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34685. */
  34686. protected _useMetallnessFromMetallicTextureBlue: boolean;
  34687. /**
  34688. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34689. */
  34690. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  34691. /**
  34692. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34693. */
  34694. protected _useAmbientInGrayScale: boolean;
  34695. /**
  34696. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34697. * The material will try to infer what glossiness each pixel should be.
  34698. */
  34699. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  34700. /**
  34701. * Defines the falloff type used in this material.
  34702. * It by default is Physical.
  34703. */
  34704. protected _lightFalloff: number;
  34705. /**
  34706. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34707. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34708. */
  34709. protected _useRadianceOverAlpha: boolean;
  34710. /**
  34711. * Allows using an object space normal map (instead of tangent space).
  34712. */
  34713. protected _useObjectSpaceNormalMap: boolean;
  34714. /**
  34715. * Allows using the bump map in parallax mode.
  34716. */
  34717. protected _useParallax: boolean;
  34718. /**
  34719. * Allows using the bump map in parallax occlusion mode.
  34720. */
  34721. protected _useParallaxOcclusion: boolean;
  34722. /**
  34723. * Controls the scale bias of the parallax mode.
  34724. */
  34725. protected _parallaxScaleBias: number;
  34726. /**
  34727. * If sets to true, disables all the lights affecting the material.
  34728. */
  34729. protected _disableLighting: boolean;
  34730. /**
  34731. * Number of Simultaneous lights allowed on the material.
  34732. */
  34733. protected _maxSimultaneousLights: number;
  34734. /**
  34735. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  34736. */
  34737. protected _invertNormalMapX: boolean;
  34738. /**
  34739. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  34740. */
  34741. protected _invertNormalMapY: boolean;
  34742. /**
  34743. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34744. */
  34745. protected _twoSidedLighting: boolean;
  34746. /**
  34747. * Defines the alpha limits in alpha test mode.
  34748. */
  34749. protected _alphaCutOff: number;
  34750. /**
  34751. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34752. */
  34753. protected _forceAlphaTest: boolean;
  34754. /**
  34755. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34756. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  34757. */
  34758. protected _useAlphaFresnel: boolean;
  34759. /**
  34760. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34761. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  34762. */
  34763. protected _useLinearAlphaFresnel: boolean;
  34764. /**
  34765. * The transparency mode of the material.
  34766. */
  34767. protected _transparencyMode: Nullable<number>;
  34768. /**
  34769. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  34770. * from cos thetav and roughness:
  34771. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  34772. */
  34773. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  34774. /**
  34775. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34776. */
  34777. protected _forceIrradianceInFragment: boolean;
  34778. /**
  34779. * Force normal to face away from face.
  34780. */
  34781. protected _forceNormalForward: boolean;
  34782. /**
  34783. * Enables specular anti aliasing in the PBR shader.
  34784. * It will both interacts on the Geometry for analytical and IBL lighting.
  34785. * It also prefilter the roughness map based on the bump values.
  34786. */
  34787. protected _enableSpecularAntiAliasing: boolean;
  34788. /**
  34789. * Default configuration related to image processing available in the PBR Material.
  34790. */
  34791. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34792. /**
  34793. * Keep track of the image processing observer to allow dispose and replace.
  34794. */
  34795. private _imageProcessingObserver;
  34796. /**
  34797. * Attaches a new image processing configuration to the PBR Material.
  34798. * @param configuration
  34799. */
  34800. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34801. /**
  34802. * Stores the available render targets.
  34803. */
  34804. private _renderTargets;
  34805. /**
  34806. * Sets the global ambient color for the material used in lighting calculations.
  34807. */
  34808. private _globalAmbientColor;
  34809. /**
  34810. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  34811. */
  34812. private _useLogarithmicDepth;
  34813. /**
  34814. * If set to true, no lighting calculations will be applied.
  34815. */
  34816. private _unlit;
  34817. /**
  34818. * Instantiates a new PBRMaterial instance.
  34819. *
  34820. * @param name The material name
  34821. * @param scene The scene the material will be use in.
  34822. */
  34823. constructor(name: string, scene: Scene);
  34824. /**
  34825. * Gets the name of the material class.
  34826. */
  34827. getClassName(): string;
  34828. /**
  34829. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  34830. */
  34831. /**
  34832. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  34833. */
  34834. useLogarithmicDepth: boolean;
  34835. /**
  34836. * Gets the current transparency mode.
  34837. */
  34838. /**
  34839. * Sets the transparency mode of the material.
  34840. *
  34841. * | Value | Type | Description |
  34842. * | ----- | ----------------------------------- | ----------- |
  34843. * | 0 | OPAQUE | |
  34844. * | 1 | ALPHATEST | |
  34845. * | 2 | ALPHABLEND | |
  34846. * | 3 | ALPHATESTANDBLEND | |
  34847. *
  34848. */
  34849. transparencyMode: Nullable<number>;
  34850. /**
  34851. * Returns true if alpha blending should be disabled.
  34852. */
  34853. private readonly _disableAlphaBlending;
  34854. /**
  34855. * Specifies whether or not this material should be rendered in alpha blend mode.
  34856. */
  34857. needAlphaBlending(): boolean;
  34858. /**
  34859. * Specifies if the mesh will require alpha blending.
  34860. * @param mesh - BJS mesh.
  34861. */
  34862. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  34863. /**
  34864. * Specifies whether or not this material should be rendered in alpha test mode.
  34865. */
  34866. needAlphaTesting(): boolean;
  34867. /**
  34868. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  34869. */
  34870. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  34871. /**
  34872. * Gets the texture used for the alpha test.
  34873. */
  34874. getAlphaTestTexture(): BaseTexture;
  34875. /**
  34876. * Stores the reflectivity values based on metallic roughness workflow.
  34877. */
  34878. private static _scaledReflectivity;
  34879. /**
  34880. * Specifies that the submesh is ready to be used.
  34881. * @param mesh - BJS mesh.
  34882. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  34883. * @param useInstances - Specifies that instances should be used.
  34884. * @returns - boolean indicating that the submesh is ready or not.
  34885. */
  34886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34887. /**
  34888. * Specifies if the material uses metallic roughness workflow.
  34889. * @returns boolean specifiying if the material uses metallic roughness workflow.
  34890. */
  34891. isMetallicWorkflow(): boolean;
  34892. private _prepareEffect;
  34893. private _prepareDefines;
  34894. /**
  34895. * Force shader compilation
  34896. */
  34897. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  34898. clipPlane: boolean;
  34899. }>): void;
  34900. /**
  34901. * Initializes the uniform buffer layout for the shader.
  34902. */
  34903. buildUniformLayout(): void;
  34904. /**
  34905. * Unbinds the textures.
  34906. */
  34907. unbind(): void;
  34908. /**
  34909. * Binds the submesh data.
  34910. * @param world - The world matrix.
  34911. * @param mesh - The BJS mesh.
  34912. * @param subMesh - A submesh of the BJS mesh.
  34913. */
  34914. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34915. /**
  34916. * Returns the animatable textures.
  34917. * @returns - Array of animatable textures.
  34918. */
  34919. getAnimatables(): IAnimatable[];
  34920. /**
  34921. * Returns the texture used for reflections.
  34922. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  34923. */
  34924. private _getReflectionTexture;
  34925. /**
  34926. * Returns the texture used for refraction or null if none is used.
  34927. * @returns - Refection texture if present. If no refraction texture and refraction
  34928. * is linked with transparency, returns environment texture. Otherwise, returns null.
  34929. */
  34930. private _getRefractionTexture;
  34931. /**
  34932. * Disposes the resources of the material.
  34933. * @param forceDisposeEffect - Forces the disposal of effects.
  34934. * @param forceDisposeTextures - Forces the disposal of all textures.
  34935. */
  34936. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34937. }
  34938. }
  34939. declare module BABYLON {
  34940. /**
  34941. * The Physically based simple base material of BJS.
  34942. *
  34943. * This enables better naming and convention enforcements on top of the pbrMaterial.
  34944. * It is used as the base class for both the specGloss and metalRough conventions.
  34945. */
  34946. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  34947. /**
  34948. * Number of Simultaneous lights allowed on the material.
  34949. */
  34950. maxSimultaneousLights: number;
  34951. /**
  34952. * If sets to true, disables all the lights affecting the material.
  34953. */
  34954. disableLighting: boolean;
  34955. /**
  34956. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  34957. */
  34958. environmentTexture: BaseTexture;
  34959. /**
  34960. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34961. */
  34962. invertNormalMapX: boolean;
  34963. /**
  34964. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34965. */
  34966. invertNormalMapY: boolean;
  34967. /**
  34968. * Normal map used in the model.
  34969. */
  34970. normalTexture: BaseTexture;
  34971. /**
  34972. * Emissivie color used to self-illuminate the model.
  34973. */
  34974. emissiveColor: Color3;
  34975. /**
  34976. * Emissivie texture used to self-illuminate the model.
  34977. */
  34978. emissiveTexture: BaseTexture;
  34979. /**
  34980. * Occlusion Channel Strenght.
  34981. */
  34982. occlusionStrength: number;
  34983. /**
  34984. * Occlusion Texture of the material (adding extra occlusion effects).
  34985. */
  34986. occlusionTexture: BaseTexture;
  34987. /**
  34988. * Defines the alpha limits in alpha test mode.
  34989. */
  34990. alphaCutOff: number;
  34991. /**
  34992. * Gets the current double sided mode.
  34993. */
  34994. /**
  34995. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34996. */
  34997. doubleSided: boolean;
  34998. lightmapTexture: BaseTexture;
  34999. useLightmapAsShadowmap: boolean;
  35000. /**
  35001. * Return the active textures of the material.
  35002. */
  35003. getActiveTextures(): BaseTexture[];
  35004. hasTexture(texture: BaseTexture): boolean;
  35005. /**
  35006. * Instantiates a new PBRMaterial instance.
  35007. *
  35008. * @param name The material name
  35009. * @param scene The scene the material will be use in.
  35010. */
  35011. constructor(name: string, scene: Scene);
  35012. getClassName(): string;
  35013. }
  35014. }
  35015. declare module BABYLON {
  35016. /**
  35017. * The Physically based material of BJS.
  35018. *
  35019. * This offers the main features of a standard PBR material.
  35020. * For more information, please refer to the documentation :
  35021. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35022. */
  35023. class PBRMaterial extends PBRBaseMaterial {
  35024. /**
  35025. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  35026. */
  35027. static readonly PBRMATERIAL_OPAQUE: number;
  35028. /**
  35029. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  35030. */
  35031. static readonly PBRMATERIAL_ALPHATEST: number;
  35032. /**
  35033. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35034. */
  35035. static readonly PBRMATERIAL_ALPHABLEND: number;
  35036. /**
  35037. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35038. * They are also discarded below the alpha cutoff threshold to improve performances.
  35039. */
  35040. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  35041. /**
  35042. * Intensity of the direct lights e.g. the four lights available in your scene.
  35043. * This impacts both the direct diffuse and specular highlights.
  35044. */
  35045. directIntensity: number;
  35046. /**
  35047. * Intensity of the emissive part of the material.
  35048. * This helps controlling the emissive effect without modifying the emissive color.
  35049. */
  35050. emissiveIntensity: number;
  35051. /**
  35052. * Intensity of the environment e.g. how much the environment will light the object
  35053. * either through harmonics for rough material or through the refelction for shiny ones.
  35054. */
  35055. environmentIntensity: number;
  35056. /**
  35057. * This is a special control allowing the reduction of the specular highlights coming from the
  35058. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35059. */
  35060. specularIntensity: number;
  35061. /**
  35062. * Debug Control allowing disabling the bump map on this material.
  35063. */
  35064. disableBumpMap: boolean;
  35065. /**
  35066. * AKA Diffuse Texture in standard nomenclature.
  35067. */
  35068. albedoTexture: BaseTexture;
  35069. /**
  35070. * AKA Occlusion Texture in other nomenclature.
  35071. */
  35072. ambientTexture: BaseTexture;
  35073. /**
  35074. * AKA Occlusion Texture Intensity in other nomenclature.
  35075. */
  35076. ambientTextureStrength: number;
  35077. /**
  35078. * Stores the alpha values in a texture.
  35079. */
  35080. opacityTexture: BaseTexture;
  35081. /**
  35082. * Stores the reflection values in a texture.
  35083. */
  35084. reflectionTexture: Nullable<BaseTexture>;
  35085. /**
  35086. * Stores the emissive values in a texture.
  35087. */
  35088. emissiveTexture: BaseTexture;
  35089. /**
  35090. * AKA Specular texture in other nomenclature.
  35091. */
  35092. reflectivityTexture: BaseTexture;
  35093. /**
  35094. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35095. */
  35096. metallicTexture: BaseTexture;
  35097. /**
  35098. * Specifies the metallic scalar of the metallic/roughness workflow.
  35099. * Can also be used to scale the metalness values of the metallic texture.
  35100. */
  35101. metallic: Nullable<number>;
  35102. /**
  35103. * Specifies the roughness scalar of the metallic/roughness workflow.
  35104. * Can also be used to scale the roughness values of the metallic texture.
  35105. */
  35106. roughness: Nullable<number>;
  35107. /**
  35108. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35109. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35110. */
  35111. microSurfaceTexture: BaseTexture;
  35112. /**
  35113. * Stores surface normal data used to displace a mesh in a texture.
  35114. */
  35115. bumpTexture: BaseTexture;
  35116. /**
  35117. * Stores the pre-calculated light information of a mesh in a texture.
  35118. */
  35119. lightmapTexture: BaseTexture;
  35120. /**
  35121. * Stores the refracted light information in a texture.
  35122. */
  35123. refractionTexture: BaseTexture;
  35124. /**
  35125. * The color of a material in ambient lighting.
  35126. */
  35127. ambientColor: Color3;
  35128. /**
  35129. * AKA Diffuse Color in other nomenclature.
  35130. */
  35131. albedoColor: Color3;
  35132. /**
  35133. * AKA Specular Color in other nomenclature.
  35134. */
  35135. reflectivityColor: Color3;
  35136. /**
  35137. * The color reflected from the material.
  35138. */
  35139. reflectionColor: Color3;
  35140. /**
  35141. * The color emitted from the material.
  35142. */
  35143. emissiveColor: Color3;
  35144. /**
  35145. * AKA Glossiness in other nomenclature.
  35146. */
  35147. microSurface: number;
  35148. /**
  35149. * source material index of refraction (IOR)' / 'destination material IOR.
  35150. */
  35151. indexOfRefraction: number;
  35152. /**
  35153. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35154. */
  35155. invertRefractionY: boolean;
  35156. /**
  35157. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35158. * Materials half opaque for instance using refraction could benefit from this control.
  35159. */
  35160. linkRefractionWithTransparency: boolean;
  35161. useLightmapAsShadowmap: boolean;
  35162. /**
  35163. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35164. */
  35165. useAlphaFromAlbedoTexture: boolean;
  35166. /**
  35167. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35168. */
  35169. forceAlphaTest: boolean;
  35170. /**
  35171. * Defines the alpha limits in alpha test mode.
  35172. */
  35173. alphaCutOff: number;
  35174. /**
  35175. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35176. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35177. */
  35178. useSpecularOverAlpha: boolean;
  35179. /**
  35180. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35181. */
  35182. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35183. /**
  35184. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35185. */
  35186. useRoughnessFromMetallicTextureAlpha: boolean;
  35187. /**
  35188. * Specifies if the metallic texture contains the roughness information in its green channel.
  35189. */
  35190. useRoughnessFromMetallicTextureGreen: boolean;
  35191. /**
  35192. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35193. */
  35194. useMetallnessFromMetallicTextureBlue: boolean;
  35195. /**
  35196. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35197. */
  35198. useAmbientOcclusionFromMetallicTextureRed: boolean;
  35199. /**
  35200. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35201. */
  35202. useAmbientInGrayScale: boolean;
  35203. /**
  35204. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35205. * The material will try to infer what glossiness each pixel should be.
  35206. */
  35207. useAutoMicroSurfaceFromReflectivityMap: boolean;
  35208. /**
  35209. * BJS is using an harcoded light falloff based on a manually sets up range.
  35210. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  35211. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  35212. */
  35213. /**
  35214. * BJS is using an harcoded light falloff based on a manually sets up range.
  35215. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  35216. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  35217. */
  35218. usePhysicalLightFalloff: boolean;
  35219. /**
  35220. * In order to support the falloff compatibility with gltf, a special mode has been added
  35221. * to reproduce the gltf light falloff.
  35222. */
  35223. /**
  35224. * In order to support the falloff compatibility with gltf, a special mode has been added
  35225. * to reproduce the gltf light falloff.
  35226. */
  35227. useGLTFLightFalloff: boolean;
  35228. /**
  35229. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35230. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35231. */
  35232. useRadianceOverAlpha: boolean;
  35233. /**
  35234. * Allows using an object space normal map (instead of tangent space).
  35235. */
  35236. useObjectSpaceNormalMap: boolean;
  35237. /**
  35238. * Allows using the bump map in parallax mode.
  35239. */
  35240. useParallax: boolean;
  35241. /**
  35242. * Allows using the bump map in parallax occlusion mode.
  35243. */
  35244. useParallaxOcclusion: boolean;
  35245. /**
  35246. * Controls the scale bias of the parallax mode.
  35247. */
  35248. parallaxScaleBias: number;
  35249. /**
  35250. * If sets to true, disables all the lights affecting the material.
  35251. */
  35252. disableLighting: boolean;
  35253. /**
  35254. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35255. */
  35256. forceIrradianceInFragment: boolean;
  35257. /**
  35258. * Number of Simultaneous lights allowed on the material.
  35259. */
  35260. maxSimultaneousLights: number;
  35261. /**
  35262. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35263. */
  35264. invertNormalMapX: boolean;
  35265. /**
  35266. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35267. */
  35268. invertNormalMapY: boolean;
  35269. /**
  35270. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35271. */
  35272. twoSidedLighting: boolean;
  35273. /**
  35274. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35275. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35276. */
  35277. useAlphaFresnel: boolean;
  35278. /**
  35279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35280. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35281. */
  35282. useLinearAlphaFresnel: boolean;
  35283. /**
  35284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35285. * And/Or occlude the blended part.
  35286. */
  35287. environmentBRDFTexture: Nullable<BaseTexture>;
  35288. /**
  35289. * Force normal to face away from face.
  35290. */
  35291. forceNormalForward: boolean;
  35292. /**
  35293. * Enables specular anti aliasing in the PBR shader.
  35294. * It will both interacts on the Geometry for analytical and IBL lighting.
  35295. * It also prefilter the roughness map based on the bump values.
  35296. */
  35297. enableSpecularAntiAliasing: boolean;
  35298. /**
  35299. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35300. * makes the reflect vector face the model (under horizon).
  35301. */
  35302. useHorizonOcclusion: boolean;
  35303. /**
  35304. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35305. * too much the area relying on ambient texture to define their ambient occlusion.
  35306. */
  35307. useRadianceOcclusion: boolean;
  35308. /**
  35309. * If set to true, no lighting calculations will be applied.
  35310. */
  35311. unlit: boolean;
  35312. /**
  35313. * Gets the image processing configuration used either in this material.
  35314. */
  35315. /**
  35316. * Sets the Default image processing configuration used either in the this material.
  35317. *
  35318. * If sets to null, the scene one is in use.
  35319. */
  35320. imageProcessingConfiguration: ImageProcessingConfiguration;
  35321. /**
  35322. * Gets wether the color curves effect is enabled.
  35323. */
  35324. /**
  35325. * Sets wether the color curves effect is enabled.
  35326. */
  35327. cameraColorCurvesEnabled: boolean;
  35328. /**
  35329. * Gets wether the color grading effect is enabled.
  35330. */
  35331. /**
  35332. * Gets wether the color grading effect is enabled.
  35333. */
  35334. cameraColorGradingEnabled: boolean;
  35335. /**
  35336. * Gets wether tonemapping is enabled or not.
  35337. */
  35338. /**
  35339. * Sets wether tonemapping is enabled or not
  35340. */
  35341. cameraToneMappingEnabled: boolean;
  35342. /**
  35343. * The camera exposure used on this material.
  35344. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35345. * This corresponds to a photographic exposure.
  35346. */
  35347. /**
  35348. * The camera exposure used on this material.
  35349. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35350. * This corresponds to a photographic exposure.
  35351. */
  35352. cameraExposure: number;
  35353. /**
  35354. * Gets The camera contrast used on this material.
  35355. */
  35356. /**
  35357. * Sets The camera contrast used on this material.
  35358. */
  35359. cameraContrast: number;
  35360. /**
  35361. * Gets the Color Grading 2D Lookup Texture.
  35362. */
  35363. /**
  35364. * Sets the Color Grading 2D Lookup Texture.
  35365. */
  35366. cameraColorGradingTexture: Nullable<BaseTexture>;
  35367. /**
  35368. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35369. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35370. * 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;
  35371. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35372. */
  35373. /**
  35374. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35375. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35376. * 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;
  35377. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35378. */
  35379. cameraColorCurves: Nullable<ColorCurves>;
  35380. /**
  35381. * Instantiates a new PBRMaterial instance.
  35382. *
  35383. * @param name The material name
  35384. * @param scene The scene the material will be use in.
  35385. */
  35386. constructor(name: string, scene: Scene);
  35387. /**
  35388. * Returns the name of this material class.
  35389. */
  35390. getClassName(): string;
  35391. /**
  35392. * Returns an array of the actively used textures.
  35393. * @returns - Array of BaseTextures
  35394. */
  35395. getActiveTextures(): BaseTexture[];
  35396. /**
  35397. * Checks to see if a texture is used in the material.
  35398. * @param texture - Base texture to use.
  35399. * @returns - Boolean specifying if a texture is used in the material.
  35400. */
  35401. hasTexture(texture: BaseTexture): boolean;
  35402. /**
  35403. * Makes a duplicate of the current material.
  35404. * @param name - name to use for the new material.
  35405. */
  35406. clone(name: string): PBRMaterial;
  35407. /**
  35408. * Serializes this PBR Material.
  35409. * @returns - An object with the serialized material.
  35410. */
  35411. serialize(): any;
  35412. /**
  35413. * Parses a PBR Material from a serialized object.
  35414. * @param source - Serialized object.
  35415. * @param scene - BJS scene instance.
  35416. * @param rootUrl - url for the scene object
  35417. * @returns - PBRMaterial
  35418. */
  35419. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  35420. }
  35421. }
  35422. declare module BABYLON {
  35423. /**
  35424. * The PBR material of BJS following the metal roughness convention.
  35425. *
  35426. * This fits to the PBR convention in the GLTF definition:
  35427. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  35428. */
  35429. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  35430. /**
  35431. * The base color has two different interpretations depending on the value of metalness.
  35432. * When the material is a metal, the base color is the specific measured reflectance value
  35433. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  35434. * of the material.
  35435. */
  35436. baseColor: Color3;
  35437. /**
  35438. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  35439. * well as opacity information in the alpha channel.
  35440. */
  35441. baseTexture: BaseTexture;
  35442. /**
  35443. * Specifies the metallic scalar value of the material.
  35444. * Can also be used to scale the metalness values of the metallic texture.
  35445. */
  35446. metallic: number;
  35447. /**
  35448. * Specifies the roughness scalar value of the material.
  35449. * Can also be used to scale the roughness values of the metallic texture.
  35450. */
  35451. roughness: number;
  35452. /**
  35453. * Texture containing both the metallic value in the B channel and the
  35454. * roughness value in the G channel to keep better precision.
  35455. */
  35456. metallicRoughnessTexture: BaseTexture;
  35457. /**
  35458. * Instantiates a new PBRMetalRoughnessMaterial instance.
  35459. *
  35460. * @param name The material name
  35461. * @param scene The scene the material will be use in.
  35462. */
  35463. constructor(name: string, scene: Scene);
  35464. /**
  35465. * Return the currrent class name of the material.
  35466. */
  35467. getClassName(): string;
  35468. /**
  35469. * Return the active textures of the material.
  35470. */
  35471. getActiveTextures(): BaseTexture[];
  35472. /**
  35473. * Checks to see if a texture is used in the material.
  35474. * @param texture - Base texture to use.
  35475. * @returns - Boolean specifying if a texture is used in the material.
  35476. */
  35477. hasTexture(texture: BaseTexture): boolean;
  35478. /**
  35479. * Makes a duplicate of the current material.
  35480. * @param name - name to use for the new material.
  35481. */
  35482. clone(name: string): PBRMetallicRoughnessMaterial;
  35483. /**
  35484. * Serialize the material to a parsable JSON object.
  35485. */
  35486. serialize(): any;
  35487. /**
  35488. * Parses a JSON object correponding to the serialize function.
  35489. */
  35490. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  35491. }
  35492. }
  35493. declare module BABYLON {
  35494. /**
  35495. * The PBR material of BJS following the specular glossiness convention.
  35496. *
  35497. * This fits to the PBR convention in the GLTF definition:
  35498. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  35499. */
  35500. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  35501. /**
  35502. * Specifies the diffuse color of the material.
  35503. */
  35504. diffuseColor: Color3;
  35505. /**
  35506. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  35507. * channel.
  35508. */
  35509. diffuseTexture: BaseTexture;
  35510. /**
  35511. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  35512. */
  35513. specularColor: Color3;
  35514. /**
  35515. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  35516. */
  35517. glossiness: number;
  35518. /**
  35519. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  35520. */
  35521. specularGlossinessTexture: BaseTexture;
  35522. /**
  35523. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  35524. *
  35525. * @param name The material name
  35526. * @param scene The scene the material will be use in.
  35527. */
  35528. constructor(name: string, scene: Scene);
  35529. /**
  35530. * Return the currrent class name of the material.
  35531. */
  35532. getClassName(): string;
  35533. /**
  35534. * Return the active textures of the material.
  35535. */
  35536. getActiveTextures(): BaseTexture[];
  35537. /**
  35538. * Checks to see if a texture is used in the material.
  35539. * @param texture - Base texture to use.
  35540. * @returns - Boolean specifying if a texture is used in the material.
  35541. */
  35542. hasTexture(texture: BaseTexture): boolean;
  35543. /**
  35544. * Makes a duplicate of the current material.
  35545. * @param name - name to use for the new material.
  35546. */
  35547. clone(name: string): PBRSpecularGlossinessMaterial;
  35548. /**
  35549. * Serialize the material to a parsable JSON object.
  35550. */
  35551. serialize(): any;
  35552. /**
  35553. * Parses a JSON object correponding to the serialize function.
  35554. */
  35555. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  35556. }
  35557. }
  35558. declare module BABYLON {
  35559. class BaseTexture {
  35560. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35561. name: string;
  35562. private _hasAlpha;
  35563. hasAlpha: boolean;
  35564. getAlphaFromRGB: boolean;
  35565. level: number;
  35566. coordinatesIndex: number;
  35567. private _coordinatesMode;
  35568. /**
  35569. * How a texture is mapped.
  35570. *
  35571. * | Value | Type | Description |
  35572. * | ----- | ----------------------------------- | ----------- |
  35573. * | 0 | EXPLICIT_MODE | |
  35574. * | 1 | SPHERICAL_MODE | |
  35575. * | 2 | PLANAR_MODE | |
  35576. * | 3 | CUBIC_MODE | |
  35577. * | 4 | PROJECTION_MODE | |
  35578. * | 5 | SKYBOX_MODE | |
  35579. * | 6 | INVCUBIC_MODE | |
  35580. * | 7 | EQUIRECTANGULAR_MODE | |
  35581. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35582. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35583. */
  35584. coordinatesMode: number;
  35585. /**
  35586. * | Value | Type | Description |
  35587. * | ----- | ------------------ | ----------- |
  35588. * | 0 | CLAMP_ADDRESSMODE | |
  35589. * | 1 | WRAP_ADDRESSMODE | |
  35590. * | 2 | MIRROR_ADDRESSMODE | |
  35591. */
  35592. wrapU: number;
  35593. /**
  35594. * | Value | Type | Description |
  35595. * | ----- | ------------------ | ----------- |
  35596. * | 0 | CLAMP_ADDRESSMODE | |
  35597. * | 1 | WRAP_ADDRESSMODE | |
  35598. * | 2 | MIRROR_ADDRESSMODE | |
  35599. */
  35600. wrapV: number;
  35601. /**
  35602. * | Value | Type | Description |
  35603. * | ----- | ------------------ | ----------- |
  35604. * | 0 | CLAMP_ADDRESSMODE | |
  35605. * | 1 | WRAP_ADDRESSMODE | |
  35606. * | 2 | MIRROR_ADDRESSMODE | |
  35607. */
  35608. wrapR: number;
  35609. anisotropicFilteringLevel: number;
  35610. isCube: boolean;
  35611. is3D: boolean;
  35612. gammaSpace: boolean;
  35613. /**
  35614. * Gets whether or not the texture contains RGBD data.
  35615. */
  35616. readonly isRGBD: boolean;
  35617. invertZ: boolean;
  35618. lodLevelInAlpha: boolean;
  35619. lodGenerationOffset: number;
  35620. lodGenerationScale: number;
  35621. isRenderTarget: boolean;
  35622. readonly uid: string;
  35623. toString(): string;
  35624. getClassName(): string;
  35625. animations: Animation[];
  35626. /**
  35627. * An event triggered when the texture is disposed.
  35628. */
  35629. onDisposeObservable: Observable<BaseTexture>;
  35630. private _onDisposeObserver;
  35631. onDispose: () => void;
  35632. delayLoadState: number;
  35633. private _scene;
  35634. _texture: Nullable<InternalTexture>;
  35635. private _uid;
  35636. readonly isBlocking: boolean;
  35637. constructor(scene: Nullable<Scene>);
  35638. getScene(): Nullable<Scene>;
  35639. getTextureMatrix(): Matrix;
  35640. getReflectionTextureMatrix(): Matrix;
  35641. getInternalTexture(): Nullable<InternalTexture>;
  35642. isReadyOrNotBlocking(): boolean;
  35643. isReady(): boolean;
  35644. private _cachedSize;
  35645. getSize(): ISize;
  35646. getBaseSize(): ISize;
  35647. scale(ratio: number): void;
  35648. readonly canRescale: boolean;
  35649. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  35650. _rebuild(): void;
  35651. delayLoad(): void;
  35652. clone(): Nullable<BaseTexture>;
  35653. readonly textureType: number;
  35654. readonly textureFormat: number;
  35655. /**
  35656. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35657. * This will returns an RGBA array buffer containing either in values (0-255) or
  35658. * float values (0-1) depending of the underlying buffer type.
  35659. * @param faceIndex The face of the texture to read (in case of cube texture)
  35660. * @param level The LOD level of the texture to read (in case of Mip Maps)
  35661. * @returns The Array buffer containing the pixels data.
  35662. */
  35663. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  35664. releaseInternalTexture(): void;
  35665. sphericalPolynomial: Nullable<SphericalPolynomial>;
  35666. readonly _lodTextureHigh: Nullable<BaseTexture>;
  35667. readonly _lodTextureMid: Nullable<BaseTexture>;
  35668. readonly _lodTextureLow: Nullable<BaseTexture>;
  35669. dispose(): void;
  35670. serialize(): any;
  35671. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35672. }
  35673. }
  35674. declare module BABYLON {
  35675. /**
  35676. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  35677. * It can help converting any input color in a desired output one. This can then be used to create effects
  35678. * from sepia, black and white to sixties or futuristic rendering...
  35679. *
  35680. * The only supported format is currently 3dl.
  35681. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  35682. */
  35683. class ColorGradingTexture extends BaseTexture {
  35684. /**
  35685. * The current texture matrix. (will always be identity in color grading texture)
  35686. */
  35687. private _textureMatrix;
  35688. /**
  35689. * The texture URL.
  35690. */
  35691. url: string;
  35692. /**
  35693. * Empty line regex stored for GC.
  35694. */
  35695. private static _noneEmptyLineRegex;
  35696. private _engine;
  35697. /**
  35698. * Instantiates a ColorGradingTexture from the following parameters.
  35699. *
  35700. * @param url The location of the color gradind data (currently only supporting 3dl)
  35701. * @param scene The scene the texture will be used in
  35702. */
  35703. constructor(url: string, scene: Scene);
  35704. /**
  35705. * Returns the texture matrix used in most of the material.
  35706. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  35707. */
  35708. getTextureMatrix(): Matrix;
  35709. /**
  35710. * Occurs when the file being loaded is a .3dl LUT file.
  35711. */
  35712. private load3dlTexture;
  35713. /**
  35714. * Starts the loading process of the texture.
  35715. */
  35716. private loadTexture;
  35717. /**
  35718. * Clones the color gradind texture.
  35719. */
  35720. clone(): ColorGradingTexture;
  35721. /**
  35722. * Called during delayed load for textures.
  35723. */
  35724. delayLoad(): void;
  35725. /**
  35726. * Parses a color grading texture serialized by Babylon.
  35727. * @param parsedTexture The texture information being parsedTexture
  35728. * @param scene The scene to load the texture in
  35729. * @param rootUrl The root url of the data assets to load
  35730. * @return A color gradind texture
  35731. */
  35732. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  35733. /**
  35734. * Serializes the LUT texture to json format.
  35735. */
  35736. serialize(): any;
  35737. }
  35738. }
  35739. declare module BABYLON {
  35740. class CubeTexture extends BaseTexture {
  35741. url: string;
  35742. /**
  35743. * Gets or sets the center of the bounding box associated with the cube texture
  35744. * It must define where the camera used to render the texture was set
  35745. */
  35746. boundingBoxPosition: Vector3;
  35747. private _boundingBoxSize;
  35748. /**
  35749. * Gets or sets the size of the bounding box associated with the cube texture
  35750. * When defined, the cubemap will switch to local mode
  35751. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35752. * @example https://www.babylonjs-playground.com/#RNASML
  35753. */
  35754. boundingBoxSize: Vector3;
  35755. protected _rotationY: number;
  35756. /**
  35757. * Sets texture matrix rotation angle around Y axis in radians.
  35758. */
  35759. /**
  35760. * Gets texture matrix rotation angle around Y axis radians.
  35761. */
  35762. rotationY: number;
  35763. private _noMipmap;
  35764. private _files;
  35765. private _extensions;
  35766. private _textureMatrix;
  35767. private _format;
  35768. private _createPolynomials;
  35769. /** @hidden */
  35770. readonly _prefiltered: boolean;
  35771. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  35772. /**
  35773. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  35774. * @param url defines the url of the prefiltered texture
  35775. * @param scene defines the scene the texture is attached to
  35776. * @param forcedExtension defines the extension of the file if different from the url
  35777. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35778. * @return the prefiltered texture
  35779. */
  35780. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  35781. /**
  35782. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  35783. * as prefiltered data.
  35784. * @param rootUrl defines the url of the texture or the root name of the six images
  35785. * @param scene defines the scene the texture is attached to
  35786. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  35787. * @param noMipmap defines if mipmaps should be created or not
  35788. * @param files defines the six files to load for the different faces
  35789. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  35790. * @param onError defines a callback triggered in case of error during load
  35791. * @param format defines the internal format to use for the texture once loaded
  35792. * @param prefiltered defines whether or not the texture is created from prefiltered data
  35793. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  35794. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35795. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  35796. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  35797. * @return the cube texture
  35798. */
  35799. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  35800. delayLoad(): void;
  35801. getReflectionTextureMatrix(): Matrix;
  35802. setReflectionTextureMatrix(value: Matrix): void;
  35803. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  35804. clone(): CubeTexture;
  35805. }
  35806. }
  35807. declare module BABYLON {
  35808. /**
  35809. * A class extending {BABYLON.Texture} allowing drawing on a texture
  35810. * @see http://doc.babylonjs.com/how_to/dynamictexture
  35811. */
  35812. class DynamicTexture extends Texture {
  35813. private _generateMipMaps;
  35814. private _canvas;
  35815. private _context;
  35816. private _engine;
  35817. /**
  35818. * Creates a {BABYLON.DynamicTexture}
  35819. * @param name defines the name of the texture
  35820. * @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
  35821. * @param scene defines the scene where you want the texture
  35822. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  35823. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  35824. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  35825. */
  35826. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  35827. /**
  35828. * Gets the current state of canRescale
  35829. */
  35830. readonly canRescale: boolean;
  35831. private _recreate;
  35832. /**
  35833. * Scales the texture
  35834. * @param ratio the scale factor to apply to both width and height
  35835. */
  35836. scale(ratio: number): void;
  35837. /**
  35838. * Resizes the texture
  35839. * @param width the new width
  35840. * @param height the new height
  35841. */
  35842. scaleTo(width: number, height: number): void;
  35843. /**
  35844. * Gets the context of the canvas used by the texture
  35845. * @returns the canvas context of the dynamic texture
  35846. */
  35847. getContext(): CanvasRenderingContext2D;
  35848. /**
  35849. * Clears the texture
  35850. */
  35851. clear(): void;
  35852. /**
  35853. * Updates the texture
  35854. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  35855. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  35856. */
  35857. update(invertY?: boolean, premulAlpha?: boolean): void;
  35858. /**
  35859. * Draws text onto the texture
  35860. * @param text defines the text to be drawn
  35861. * @param x defines the placement of the text from the left
  35862. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  35863. * @param font defines the font to be used with font-style, font-size, font-name
  35864. * @param color defines the color used for the text
  35865. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  35866. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  35867. * @param update defines whether texture is immediately update (default is true)
  35868. */
  35869. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  35870. /**
  35871. * Clones the texture
  35872. * @returns the clone of the texture.
  35873. */
  35874. clone(): DynamicTexture;
  35875. /**
  35876. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  35877. * @returns a serialized dynamic texture object
  35878. */
  35879. serialize(): any;
  35880. /** @hidden */
  35881. _rebuild(): void;
  35882. }
  35883. }
  35884. declare module BABYLON {
  35885. /**
  35886. * This represents a texture coming from an HDR input.
  35887. *
  35888. * The only supported format is currently panorama picture stored in RGBE format.
  35889. * Example of such files can be found on HDRLib: http://hdrlib.com/
  35890. */
  35891. class HDRCubeTexture extends BaseTexture {
  35892. private static _facesMapping;
  35893. private _generateHarmonics;
  35894. private _noMipmap;
  35895. private _textureMatrix;
  35896. private _size;
  35897. private _onLoad;
  35898. private _onError;
  35899. /**
  35900. * The texture URL.
  35901. */
  35902. url: string;
  35903. /**
  35904. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  35905. */
  35906. coordinatesMode: number;
  35907. protected _isBlocking: boolean;
  35908. /**
  35909. * Sets wether or not the texture is blocking during loading.
  35910. */
  35911. /**
  35912. * Gets wether or not the texture is blocking during loading.
  35913. */
  35914. isBlocking: boolean;
  35915. protected _rotationY: number;
  35916. /**
  35917. * Sets texture matrix rotation angle around Y axis in radians.
  35918. */
  35919. /**
  35920. * Gets texture matrix rotation angle around Y axis radians.
  35921. */
  35922. rotationY: number;
  35923. /**
  35924. * Gets or sets the center of the bounding box associated with the cube texture
  35925. * It must define where the camera used to render the texture was set
  35926. */
  35927. boundingBoxPosition: Vector3;
  35928. private _boundingBoxSize;
  35929. /**
  35930. * Gets or sets the size of the bounding box associated with the cube texture
  35931. * When defined, the cubemap will switch to local mode
  35932. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35933. * @example https://www.babylonjs-playground.com/#RNASML
  35934. */
  35935. boundingBoxSize: Vector3;
  35936. /**
  35937. * Instantiates an HDRTexture from the following parameters.
  35938. *
  35939. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  35940. * @param scene The scene the texture will be used in
  35941. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  35942. * @param noMipmap Forces to not generate the mipmap if true
  35943. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  35944. * @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)
  35945. * @param reserved Reserved flag for internal use.
  35946. */
  35947. 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>);
  35948. /**
  35949. * Occurs when the file is raw .hdr file.
  35950. */
  35951. private loadTexture;
  35952. clone(): HDRCubeTexture;
  35953. delayLoad(): void;
  35954. getReflectionTextureMatrix(): Matrix;
  35955. setReflectionTextureMatrix(value: Matrix): void;
  35956. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  35957. serialize(): any;
  35958. }
  35959. }
  35960. declare module BABYLON {
  35961. /**
  35962. * Class used to store data associated with WebGL texture data for the engine
  35963. * This class should not be used directly
  35964. */
  35965. class InternalTexture implements IInternalTextureTracker {
  35966. /**
  35967. * The source of the texture data is unknown
  35968. */
  35969. static DATASOURCE_UNKNOWN: number;
  35970. /**
  35971. * Texture data comes from an URL
  35972. */
  35973. static DATASOURCE_URL: number;
  35974. /**
  35975. * Texture data is only used for temporary storage
  35976. */
  35977. static DATASOURCE_TEMP: number;
  35978. /**
  35979. * Texture data comes from raw data (ArrayBuffer)
  35980. */
  35981. static DATASOURCE_RAW: number;
  35982. /**
  35983. * Texture content is dynamic (video or dynamic texture)
  35984. */
  35985. static DATASOURCE_DYNAMIC: number;
  35986. /**
  35987. * Texture content is generated by rendering to it
  35988. */
  35989. static DATASOURCE_RENDERTARGET: number;
  35990. /**
  35991. * Texture content is part of a multi render target process
  35992. */
  35993. static DATASOURCE_MULTIRENDERTARGET: number;
  35994. /**
  35995. * Texture data comes from a cube data file
  35996. */
  35997. static DATASOURCE_CUBE: number;
  35998. /**
  35999. * Texture data comes from a raw cube data
  36000. */
  36001. static DATASOURCE_CUBERAW: number;
  36002. /**
  36003. * Texture data come from a prefiltered cube data file
  36004. */
  36005. static DATASOURCE_CUBEPREFILTERED: number;
  36006. /**
  36007. * Texture content is raw 3D data
  36008. */
  36009. static DATASOURCE_RAW3D: number;
  36010. /**
  36011. * Texture content is a depth texture
  36012. */
  36013. static DATASOURCE_DEPTHTEXTURE: number;
  36014. /**
  36015. * Texture data comes from a raw cube data encoded with RGBD
  36016. */
  36017. static DATASOURCE_CUBERAW_RGBD: number;
  36018. /**
  36019. * Defines if the texture is ready
  36020. */
  36021. isReady: boolean;
  36022. /**
  36023. * Defines if the texture is a cube texture
  36024. */
  36025. isCube: boolean;
  36026. /**
  36027. * Defines if the texture contains 3D data
  36028. */
  36029. is3D: boolean;
  36030. /**
  36031. * Gets the URL used to load this texture
  36032. */
  36033. url: string;
  36034. /**
  36035. * Gets the sampling mode of the texture
  36036. */
  36037. samplingMode: number;
  36038. /**
  36039. * Gets a boolean indicating if the texture needs mipmaps generation
  36040. */
  36041. generateMipMaps: boolean;
  36042. /**
  36043. * Gets the number of samples used by the texture (WebGL2+ only)
  36044. */
  36045. samples: number;
  36046. /**
  36047. * Gets the type of the texture
  36048. */
  36049. type: number;
  36050. /**
  36051. * Gets the format of the texture
  36052. */
  36053. format: number;
  36054. /**
  36055. * Observable called when the texture is loaded
  36056. */
  36057. onLoadedObservable: Observable<InternalTexture>;
  36058. /**
  36059. * Gets the width of the texture
  36060. */
  36061. width: number;
  36062. /**
  36063. * Gets the height of the texture
  36064. */
  36065. height: number;
  36066. /**
  36067. * Gets the depth of the texture
  36068. */
  36069. depth: number;
  36070. /**
  36071. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36072. */
  36073. baseWidth: number;
  36074. /**
  36075. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36076. */
  36077. baseHeight: number;
  36078. /**
  36079. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36080. */
  36081. baseDepth: number;
  36082. /**
  36083. * Gets a boolean indicating if the texture is inverted on Y axis
  36084. */
  36085. invertY: boolean;
  36086. /**
  36087. * Gets or set the previous tracker in the list
  36088. */
  36089. previous: Nullable<IInternalTextureTracker>;
  36090. /**
  36091. * Gets or set the next tracker in the list
  36092. */
  36093. next: Nullable<IInternalTextureTracker>;
  36094. /** @hidden */
  36095. _initialSlot: number;
  36096. /** @hidden */
  36097. _designatedSlot: number;
  36098. /** @hidden */
  36099. _dataSource: number;
  36100. /** @hidden */
  36101. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  36102. /** @hidden */
  36103. _bufferView: Nullable<ArrayBufferView>;
  36104. /** @hidden */
  36105. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36106. /** @hidden */
  36107. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36108. /** @hidden */
  36109. _size: number;
  36110. /** @hidden */
  36111. _extension: string;
  36112. /** @hidden */
  36113. _files: Nullable<string[]>;
  36114. /** @hidden */
  36115. _workingCanvas: HTMLCanvasElement;
  36116. /** @hidden */
  36117. _workingContext: CanvasRenderingContext2D;
  36118. /** @hidden */
  36119. _framebuffer: Nullable<WebGLFramebuffer>;
  36120. /** @hidden */
  36121. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36122. /** @hidden */
  36123. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36124. /** @hidden */
  36125. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36126. /** @hidden */
  36127. _attachments: Nullable<number[]>;
  36128. /** @hidden */
  36129. _cachedCoordinatesMode: Nullable<number>;
  36130. /** @hidden */
  36131. _cachedWrapU: Nullable<number>;
  36132. /** @hidden */
  36133. _cachedWrapV: Nullable<number>;
  36134. /** @hidden */
  36135. _cachedWrapR: Nullable<number>;
  36136. /** @hidden */
  36137. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36138. /** @hidden */
  36139. _isDisabled: boolean;
  36140. /** @hidden */
  36141. _compression: Nullable<string>;
  36142. /** @hidden */
  36143. _generateStencilBuffer: boolean;
  36144. /** @hidden */
  36145. _generateDepthBuffer: boolean;
  36146. /** @hidden */
  36147. _comparisonFunction: number;
  36148. /** @hidden */
  36149. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36150. /** @hidden */
  36151. _lodGenerationScale: number;
  36152. /** @hidden */
  36153. _lodGenerationOffset: number;
  36154. /** @hidden */
  36155. _lodTextureHigh: BaseTexture;
  36156. /** @hidden */
  36157. _lodTextureMid: BaseTexture;
  36158. /** @hidden */
  36159. _lodTextureLow: BaseTexture;
  36160. /** @hidden */
  36161. _isRGBD: boolean;
  36162. /** @hidden */
  36163. _webGLTexture: Nullable<WebGLTexture>;
  36164. /** @hidden */
  36165. _references: number;
  36166. private _engine;
  36167. /**
  36168. * Gets the Engine the texture belongs to.
  36169. * @returns The babylon engine
  36170. */
  36171. getEngine(): Engine;
  36172. /**
  36173. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  36174. */
  36175. readonly dataSource: number;
  36176. /**
  36177. * Creates a new InternalTexture
  36178. * @param engine defines the engine to use
  36179. * @param dataSource defines the type of data that will be used
  36180. */
  36181. constructor(engine: Engine, dataSource: number);
  36182. /**
  36183. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  36184. */
  36185. incrementReferences(): void;
  36186. /**
  36187. * Change the size of the texture (not the size of the content)
  36188. * @param width defines the new width
  36189. * @param height defines the new height
  36190. * @param depth defines the new depth (1 by default)
  36191. */
  36192. updateSize(width: int, height: int, depth?: int): void;
  36193. /** @hidden */
  36194. _rebuild(): void;
  36195. _swapAndDie(target: InternalTexture): void;
  36196. /**
  36197. * Dispose the current allocated resources
  36198. */
  36199. dispose(): void;
  36200. }
  36201. }
  36202. declare module BABYLON {
  36203. /**
  36204. * This represents the required contract to create a new type of texture loader.
  36205. */
  36206. interface IInternalTextureLoader {
  36207. /**
  36208. * Defines wether the loader supports cascade loading the different faces.
  36209. */
  36210. supportCascades: boolean;
  36211. /**
  36212. * This returns if the loader support the current file information.
  36213. * @param extension defines the file extension of the file being loaded
  36214. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36215. * @param fallback defines the fallback internal texture if any
  36216. * @param isBase64 defines whether the texture is encoded as a base64
  36217. * @param isBuffer defines whether the texture data are stored as a buffer
  36218. * @returns true if the loader can load the specified file
  36219. */
  36220. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  36221. /**
  36222. * Transform the url before loading if required.
  36223. * @param rootUrl the url of the texture
  36224. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36225. * @returns the transformed texture
  36226. */
  36227. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  36228. /**
  36229. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  36230. * @param rootUrl the url of the texture
  36231. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36232. * @returns the fallback texture
  36233. */
  36234. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  36235. /**
  36236. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  36237. * @param data contains the texture data
  36238. * @param texture defines the BabylonJS internal texture
  36239. * @param createPolynomials will be true if polynomials have been requested
  36240. * @param onLoad defines the callback to trigger once the texture is ready
  36241. * @param onError defines the callback to trigger in case of error
  36242. */
  36243. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  36244. /**
  36245. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  36246. * @param data contains the texture data
  36247. * @param texture defines the BabylonJS internal texture
  36248. * @param callback defines the method to call once ready to upload
  36249. */
  36250. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  36251. }
  36252. }
  36253. declare module BABYLON {
  36254. /**
  36255. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  36256. */
  36257. interface IInternalTextureTracker {
  36258. /**
  36259. * Gets or set the previous tracker in the list
  36260. */
  36261. previous: Nullable<IInternalTextureTracker>;
  36262. /**
  36263. * Gets or set the next tracker in the list
  36264. */
  36265. next: Nullable<IInternalTextureTracker>;
  36266. }
  36267. /**
  36268. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  36269. */
  36270. class DummyInternalTextureTracker {
  36271. /**
  36272. * Gets or set the previous tracker in the list
  36273. */
  36274. previous: Nullable<IInternalTextureTracker>;
  36275. /**
  36276. * Gets or set the next tracker in the list
  36277. */
  36278. next: Nullable<IInternalTextureTracker>;
  36279. }
  36280. }
  36281. declare module BABYLON {
  36282. class MirrorTexture extends RenderTargetTexture {
  36283. private scene;
  36284. mirrorPlane: Plane;
  36285. private _transformMatrix;
  36286. private _mirrorMatrix;
  36287. private _savedViewMatrix;
  36288. private _blurX;
  36289. private _blurY;
  36290. private _adaptiveBlurKernel;
  36291. private _blurKernelX;
  36292. private _blurKernelY;
  36293. private _blurRatio;
  36294. blurRatio: number;
  36295. adaptiveBlurKernel: number;
  36296. blurKernel: number;
  36297. blurKernelX: number;
  36298. blurKernelY: number;
  36299. private _autoComputeBlurKernel;
  36300. protected _onRatioRescale(): void;
  36301. private _updateGammaSpace;
  36302. private _imageProcessingConfigChangeObserver;
  36303. constructor(name: string, size: number | {
  36304. width: number;
  36305. height: number;
  36306. } | {
  36307. ratio: number;
  36308. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  36309. private _preparePostProcesses;
  36310. clone(): MirrorTexture;
  36311. serialize(): any;
  36312. dispose(): void;
  36313. }
  36314. }
  36315. declare module BABYLON {
  36316. interface IMultiRenderTargetOptions {
  36317. generateMipMaps?: boolean;
  36318. types?: number[];
  36319. samplingModes?: number[];
  36320. generateDepthBuffer?: boolean;
  36321. generateStencilBuffer?: boolean;
  36322. generateDepthTexture?: boolean;
  36323. textureCount?: number;
  36324. doNotChangeAspectRatio?: boolean;
  36325. defaultType?: number;
  36326. }
  36327. class MultiRenderTarget extends RenderTargetTexture {
  36328. private _internalTextures;
  36329. private _textures;
  36330. readonly isSupported: boolean;
  36331. private _multiRenderTargetOptions;
  36332. readonly textures: Texture[];
  36333. readonly depthTexture: Texture;
  36334. wrapU: number;
  36335. wrapV: number;
  36336. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  36337. _rebuild(): void;
  36338. private _createInternalTextures;
  36339. private _createTextures;
  36340. samples: number;
  36341. resize(size: any): void;
  36342. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  36343. dispose(): void;
  36344. releaseInternalTextures(): void;
  36345. }
  36346. }
  36347. declare module BABYLON {
  36348. /**
  36349. * Raw cube texture where the raw buffers are passed in
  36350. */
  36351. class RawCubeTexture extends CubeTexture {
  36352. /**
  36353. * Creates a cube texture where the raw buffers are passed in.
  36354. * @param scene defines the scene the texture is attached to
  36355. * @param data defines the array of data to use to create each face
  36356. * @param size defines the size of the textures
  36357. * @param format defines the format of the data
  36358. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  36359. * @param generateMipMaps defines if the engine should generate the mip levels
  36360. * @param invertY defines if data must be stored with Y axis inverted
  36361. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  36362. * @param compression defines the compression used (null by default)
  36363. */
  36364. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  36365. /**
  36366. * Updates the raw cube texture.
  36367. * @param data defines the data to store
  36368. * @param format defines the data format
  36369. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36370. * @param invertY defines if data must be stored with Y axis inverted
  36371. * @param compression defines the compression used (null by default)
  36372. * @param level defines which level of the texture to update
  36373. */
  36374. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  36375. /**
  36376. * Updates a raw cube texture with RGBD encoded data.
  36377. * @param data defines the array of data [mipmap][face] to use to create each face
  36378. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  36379. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36380. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36381. * @returns a promsie that resolves when the operation is complete
  36382. */
  36383. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  36384. /**
  36385. * Clones the raw cube texture.
  36386. * @return a new cube texture
  36387. */
  36388. clone(): CubeTexture;
  36389. /** @hidden */
  36390. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  36391. }
  36392. }
  36393. declare module BABYLON {
  36394. class RawTexture extends Texture {
  36395. format: number;
  36396. private _engine;
  36397. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  36398. update(data: ArrayBufferView): void;
  36399. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36400. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36401. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36402. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36403. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36404. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36405. }
  36406. }
  36407. declare module BABYLON {
  36408. /**
  36409. * Class used to store 3D textures containing user data
  36410. */
  36411. class RawTexture3D extends Texture {
  36412. /** Gets or sets the texture format to use */
  36413. format: number;
  36414. private _engine;
  36415. /**
  36416. * Create a new RawTexture3D
  36417. * @param data defines the data of the texture
  36418. * @param width defines the width of the texture
  36419. * @param height defines the height of the texture
  36420. * @param depth defines the depth of the texture
  36421. * @param format defines the texture format to use
  36422. * @param scene defines the hosting scene
  36423. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  36424. * @param invertY defines if texture must be stored with Y axis inverted
  36425. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  36426. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  36427. */
  36428. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  36429. /** Gets or sets the texture format to use */
  36430. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  36431. /**
  36432. * Update the texture with new data
  36433. * @param data defines the data to store in the texture
  36434. */
  36435. update(data: ArrayBufferView): void;
  36436. }
  36437. }
  36438. declare module BABYLON {
  36439. /**
  36440. * Creates a refraction texture used by refraction channel of the standard material.
  36441. * @param name the texture name
  36442. * @param size size of the underlying texture
  36443. * @param scene root scene
  36444. */
  36445. class RefractionTexture extends RenderTargetTexture {
  36446. refractionPlane: Plane;
  36447. depth: number;
  36448. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  36449. clone(): RefractionTexture;
  36450. serialize(): any;
  36451. }
  36452. }
  36453. declare module BABYLON {
  36454. class RenderTargetTexture extends Texture {
  36455. isCube: boolean;
  36456. static _REFRESHRATE_RENDER_ONCE: number;
  36457. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  36458. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  36459. static readonly REFRESHRATE_RENDER_ONCE: number;
  36460. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  36461. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  36462. /**
  36463. * Use this predicate to dynamically define the list of mesh you want to render.
  36464. * If set, the renderList property will be overwritten.
  36465. */
  36466. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  36467. private _renderList;
  36468. /**
  36469. * Use this list to define the list of mesh you want to render.
  36470. */
  36471. renderList: Nullable<Array<AbstractMesh>>;
  36472. private _hookArray;
  36473. renderParticles: boolean;
  36474. renderSprites: boolean;
  36475. coordinatesMode: number;
  36476. activeCamera: Nullable<Camera>;
  36477. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  36478. useCameraPostProcesses: boolean;
  36479. ignoreCameraViewport: boolean;
  36480. private _postProcessManager;
  36481. private _postProcesses;
  36482. private _resizeObserver;
  36483. /**
  36484. * An event triggered when the texture is unbind.
  36485. */
  36486. onBeforeBindObservable: Observable<RenderTargetTexture>;
  36487. /**
  36488. * An event triggered when the texture is unbind.
  36489. */
  36490. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  36491. private _onAfterUnbindObserver;
  36492. onAfterUnbind: () => void;
  36493. /**
  36494. * An event triggered before rendering the texture
  36495. */
  36496. onBeforeRenderObservable: Observable<number>;
  36497. private _onBeforeRenderObserver;
  36498. onBeforeRender: (faceIndex: number) => void;
  36499. /**
  36500. * An event triggered after rendering the texture
  36501. */
  36502. onAfterRenderObservable: Observable<number>;
  36503. private _onAfterRenderObserver;
  36504. onAfterRender: (faceIndex: number) => void;
  36505. /**
  36506. * An event triggered after the texture clear
  36507. */
  36508. onClearObservable: Observable<Engine>;
  36509. private _onClearObserver;
  36510. onClear: (Engine: Engine) => void;
  36511. clearColor: Color4;
  36512. protected _size: number | {
  36513. width: number;
  36514. height: number;
  36515. };
  36516. protected _initialSizeParameter: number | {
  36517. width: number;
  36518. height: number;
  36519. } | {
  36520. ratio: number;
  36521. };
  36522. protected _sizeRatio: Nullable<number>;
  36523. _generateMipMaps: boolean;
  36524. protected _renderingManager: RenderingManager;
  36525. _waitingRenderList: string[];
  36526. protected _doNotChangeAspectRatio: boolean;
  36527. protected _currentRefreshId: number;
  36528. protected _refreshRate: number;
  36529. protected _textureMatrix: Matrix;
  36530. protected _samples: number;
  36531. protected _renderTargetOptions: RenderTargetCreationOptions;
  36532. readonly renderTargetOptions: RenderTargetCreationOptions;
  36533. protected _engine: Engine;
  36534. protected _onRatioRescale(): void;
  36535. /**
  36536. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  36537. * It must define where the camera used to render the texture is set
  36538. */
  36539. boundingBoxPosition: Vector3;
  36540. private _boundingBoxSize;
  36541. /**
  36542. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  36543. * When defined, the cubemap will switch to local mode
  36544. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36545. * @example https://www.babylonjs-playground.com/#RNASML
  36546. */
  36547. boundingBoxSize: Vector3;
  36548. /**
  36549. * In case the RTT has been created with a depth texture, get the associated
  36550. * depth texture.
  36551. * Otherwise, return null.
  36552. */
  36553. depthStencilTexture: Nullable<InternalTexture>;
  36554. /**
  36555. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  36556. * or used a shadow, depth texture...
  36557. * @param name The friendly name of the texture
  36558. * @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)
  36559. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  36560. * @param generateMipMaps True if mip maps need to be generated after render.
  36561. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  36562. * @param type The type of the buffer in the RTT (int, half float, float...)
  36563. * @param isCube True if a cube texture needs to be created
  36564. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  36565. * @param generateDepthBuffer True to generate a depth buffer
  36566. * @param generateStencilBuffer True to generate a stencil buffer
  36567. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  36568. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  36569. */
  36570. constructor(name: string, size: number | {
  36571. width: number;
  36572. height: number;
  36573. } | {
  36574. ratio: number;
  36575. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  36576. /**
  36577. * Creates a depth stencil texture.
  36578. * This is only available in WebGL 2 or with the depth texture extension available.
  36579. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  36580. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  36581. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  36582. */
  36583. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  36584. private _processSizeParameter;
  36585. samples: number;
  36586. resetRefreshCounter(): void;
  36587. refreshRate: number;
  36588. addPostProcess(postProcess: PostProcess): void;
  36589. clearPostProcesses(dispose?: boolean): void;
  36590. removePostProcess(postProcess: PostProcess): void;
  36591. _shouldRender(): boolean;
  36592. getRenderSize(): number;
  36593. getRenderWidth(): number;
  36594. getRenderHeight(): number;
  36595. readonly canRescale: boolean;
  36596. scale(ratio: number): void;
  36597. getReflectionTextureMatrix(): Matrix;
  36598. resize(size: number | {
  36599. width: number;
  36600. height: number;
  36601. } | {
  36602. ratio: number;
  36603. }): void;
  36604. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  36605. private _bestReflectionRenderTargetDimension;
  36606. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  36607. private renderToTarget;
  36608. /**
  36609. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36610. * This allowed control for front to back rendering or reversly depending of the special needs.
  36611. *
  36612. * @param renderingGroupId The rendering group id corresponding to its index
  36613. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36614. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36615. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36616. */
  36617. 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;
  36618. /**
  36619. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36620. *
  36621. * @param renderingGroupId The rendering group id corresponding to its index
  36622. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36623. */
  36624. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  36625. clone(): RenderTargetTexture;
  36626. serialize(): any;
  36627. disposeFramebufferObjects(): void;
  36628. dispose(): void;
  36629. _rebuild(): void;
  36630. /**
  36631. * Clear the info related to rendering groups preventing retention point in material dispose.
  36632. */
  36633. freeRenderingGroups(): void;
  36634. }
  36635. }
  36636. declare module BABYLON {
  36637. class Texture extends BaseTexture {
  36638. static NEAREST_SAMPLINGMODE: number;
  36639. static NEAREST_NEAREST_MIPLINEAR: number;
  36640. static BILINEAR_SAMPLINGMODE: number;
  36641. static LINEAR_LINEAR_MIPNEAREST: number;
  36642. static TRILINEAR_SAMPLINGMODE: number;
  36643. static LINEAR_LINEAR_MIPLINEAR: number;
  36644. static NEAREST_NEAREST_MIPNEAREST: number;
  36645. static NEAREST_LINEAR_MIPNEAREST: number;
  36646. static NEAREST_LINEAR_MIPLINEAR: number;
  36647. static NEAREST_LINEAR: number;
  36648. static NEAREST_NEAREST: number;
  36649. static LINEAR_NEAREST_MIPNEAREST: number;
  36650. static LINEAR_NEAREST_MIPLINEAR: number;
  36651. static LINEAR_LINEAR: number;
  36652. static LINEAR_NEAREST: number;
  36653. static EXPLICIT_MODE: number;
  36654. static SPHERICAL_MODE: number;
  36655. static PLANAR_MODE: number;
  36656. static CUBIC_MODE: number;
  36657. static PROJECTION_MODE: number;
  36658. static SKYBOX_MODE: number;
  36659. static INVCUBIC_MODE: number;
  36660. static EQUIRECTANGULAR_MODE: number;
  36661. static FIXED_EQUIRECTANGULAR_MODE: number;
  36662. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36663. static readonly CLAMP_ADDRESSMODE: number;
  36664. static readonly WRAP_ADDRESSMODE: number;
  36665. static readonly MIRROR_ADDRESSMODE: number;
  36666. /**
  36667. * 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
  36668. */
  36669. static UseSerializedUrlIfAny: boolean;
  36670. url: Nullable<string>;
  36671. uOffset: number;
  36672. vOffset: number;
  36673. uScale: number;
  36674. vScale: number;
  36675. uAng: number;
  36676. vAng: number;
  36677. wAng: number;
  36678. /**
  36679. * Defines the center of rotation (U)
  36680. */
  36681. uRotationCenter: number;
  36682. /**
  36683. * Defines the center of rotation (V)
  36684. */
  36685. vRotationCenter: number;
  36686. /**
  36687. * Defines the center of rotation (W)
  36688. */
  36689. wRotationCenter: number;
  36690. readonly noMipmap: boolean;
  36691. private _noMipmap;
  36692. _invertY: boolean;
  36693. private _rowGenerationMatrix;
  36694. private _cachedTextureMatrix;
  36695. private _projectionModeMatrix;
  36696. private _t0;
  36697. private _t1;
  36698. private _t2;
  36699. private _cachedUOffset;
  36700. private _cachedVOffset;
  36701. private _cachedUScale;
  36702. private _cachedVScale;
  36703. private _cachedUAng;
  36704. private _cachedVAng;
  36705. private _cachedWAng;
  36706. private _cachedProjectionMatrixId;
  36707. private _cachedCoordinatesMode;
  36708. _samplingMode: number;
  36709. /** @hidden */
  36710. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  36711. private _deleteBuffer;
  36712. protected _format: Nullable<number>;
  36713. private _delayedOnLoad;
  36714. private _delayedOnError;
  36715. protected _onLoadObservable: Nullable<Observable<Texture>>;
  36716. protected _isBlocking: boolean;
  36717. isBlocking: boolean;
  36718. readonly samplingMode: number;
  36719. 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);
  36720. /**
  36721. * Update the url (and optional buffer) of this texture if url was null during construction.
  36722. * @param url the url of the texture
  36723. * @param buffer the buffer of the texture (defaults to null)
  36724. */
  36725. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  36726. delayLoad(): void;
  36727. updateSamplingMode(samplingMode: number): void;
  36728. private _prepareRowForTextureGeneration;
  36729. getTextureMatrix(): Matrix;
  36730. getReflectionTextureMatrix(): Matrix;
  36731. clone(): Texture;
  36732. readonly onLoadObservable: Observable<Texture>;
  36733. serialize(): any;
  36734. getClassName(): string;
  36735. dispose(): void;
  36736. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  36737. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  36738. 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;
  36739. }
  36740. }
  36741. declare module BABYLON {
  36742. /**
  36743. * Settings for finer control over video usage
  36744. */
  36745. interface VideoTextureSettings {
  36746. /**
  36747. * Applies `autoplay` to video, if specified
  36748. */
  36749. autoPlay?: boolean;
  36750. /**
  36751. * Applies `loop` to video, if specified
  36752. */
  36753. loop?: boolean;
  36754. /**
  36755. * Automatically updates internal texture from video at every frame in the render loop
  36756. */
  36757. autoUpdateTexture: boolean;
  36758. /**
  36759. * Image src displayed during the video loading or until the user interacts with the video.
  36760. */
  36761. poster?: string;
  36762. }
  36763. class VideoTexture extends Texture {
  36764. /**
  36765. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36766. */
  36767. readonly autoUpdateTexture: boolean;
  36768. /**
  36769. * The video instance used by the texture internally
  36770. */
  36771. readonly video: HTMLVideoElement;
  36772. private _onUserActionRequestedObservable;
  36773. readonly onUserActionRequestedObservable: Observable<Texture>;
  36774. private _generateMipMaps;
  36775. private _engine;
  36776. private _stillImageCaptured;
  36777. private _poster;
  36778. /**
  36779. * Creates a video texture.
  36780. * Sample : https://doc.babylonjs.com/how_to/video_texture
  36781. * @param {string | null} name optional name, will detect from video source, if not defined
  36782. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  36783. * @param {BABYLON.Scene} scene is obviously the current scene.
  36784. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36785. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  36786. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36787. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  36788. */
  36789. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36790. private _getName;
  36791. private _getVideo;
  36792. private _createInternalTexture;
  36793. private reset;
  36794. /**
  36795. * Internal method to initiate `update`.
  36796. */
  36797. _rebuild(): void;
  36798. /**
  36799. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36800. */
  36801. update(): void;
  36802. /**
  36803. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36804. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36805. */
  36806. updateTexture(isVisible: boolean): void;
  36807. protected _updateInternalTexture: (e?: Event | undefined) => void;
  36808. /**
  36809. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36810. * @param url New url.
  36811. */
  36812. updateURL(url: string): void;
  36813. dispose(): void;
  36814. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36815. minWidth: number;
  36816. maxWidth: number;
  36817. minHeight: number;
  36818. maxHeight: number;
  36819. deviceId: string;
  36820. }): void;
  36821. }
  36822. }
  36823. declare var DracoDecoderModule: any;
  36824. declare var WebAssembly: any;
  36825. declare module BABYLON {
  36826. /**
  36827. * Configuration for Draco compression
  36828. */
  36829. interface IDracoCompressionConfiguration {
  36830. /**
  36831. * Configuration for the decoder.
  36832. */
  36833. decoder?: {
  36834. /**
  36835. * The url to the WebAssembly module.
  36836. */
  36837. wasmUrl?: string;
  36838. /**
  36839. * The url to the WebAssembly binary.
  36840. */
  36841. wasmBinaryUrl?: string;
  36842. /**
  36843. * The url to the fallback JavaScript module.
  36844. */
  36845. fallbackUrl?: string;
  36846. };
  36847. }
  36848. /**
  36849. * Draco compression (https://google.github.io/draco/)
  36850. *
  36851. * This class wraps the Draco module.
  36852. *
  36853. * **Encoder**
  36854. *
  36855. * The encoder is not currently implemented.
  36856. *
  36857. * **Decoder**
  36858. *
  36859. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  36860. *
  36861. * To update the configuration, use the following code:
  36862. * ```javascript
  36863. * BABYLON.DracoCompression.Configuration = {
  36864. * decoder: {
  36865. * wasmUrl: "<url to the WebAssembly library>",
  36866. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  36867. * fallbackUrl: "<url to the fallback JavaScript library>",
  36868. * }
  36869. * };
  36870. * ```
  36871. *
  36872. * 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.
  36873. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  36874. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  36875. *
  36876. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  36877. * ```javascript
  36878. * var dracoCompression = new BABYLON.DracoCompression();
  36879. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  36880. * [BABYLON.VertexBuffer.PositionKind]: 0
  36881. * });
  36882. * ```
  36883. *
  36884. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  36885. */
  36886. class DracoCompression implements IDisposable {
  36887. private static _DecoderModulePromise;
  36888. /**
  36889. * The configuration. Defaults to the following urls:
  36890. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  36891. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  36892. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  36893. */
  36894. static Configuration: IDracoCompressionConfiguration;
  36895. /**
  36896. * Returns true if the decoder is available.
  36897. */
  36898. static readonly DecoderAvailable: boolean;
  36899. /**
  36900. * Constructor
  36901. */
  36902. constructor();
  36903. /**
  36904. * Stop all async operations and release resources.
  36905. */
  36906. dispose(): void;
  36907. /**
  36908. * Decode Draco compressed mesh data to vertex data.
  36909. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  36910. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  36911. * @returns A promise that resolves with the decoded vertex data
  36912. */
  36913. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  36914. [kind: string]: number;
  36915. }): Promise<VertexData>;
  36916. private static _GetDecoderModule;
  36917. private static _LoadScriptAsync;
  36918. private static _LoadFileAsync;
  36919. }
  36920. }
  36921. declare module BABYLON {
  36922. /**
  36923. * Particle emitter emitting particles from the inside of a box.
  36924. * It emits the particles randomly between 2 given directions.
  36925. */
  36926. class BoxParticleEmitter implements IParticleEmitterType {
  36927. /**
  36928. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  36929. */
  36930. direction1: Vector3;
  36931. /**
  36932. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  36933. */
  36934. direction2: Vector3;
  36935. /**
  36936. * 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.
  36937. */
  36938. minEmitBox: Vector3;
  36939. /**
  36940. * 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.
  36941. */
  36942. maxEmitBox: Vector3;
  36943. /**
  36944. * Creates a new instance BoxParticleEmitter
  36945. */
  36946. constructor();
  36947. /**
  36948. * Called by the particle System when the direction is computed for the created particle.
  36949. * @param worldMatrix is the world matrix of the particle system
  36950. * @param directionToUpdate is the direction vector to update with the result
  36951. * @param particle is the particle we are computed the direction for
  36952. */
  36953. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36954. /**
  36955. * Called by the particle System when the position is computed for the created particle.
  36956. * @param worldMatrix is the world matrix of the particle system
  36957. * @param positionToUpdate is the position vector to update with the result
  36958. * @param particle is the particle we are computed the position for
  36959. */
  36960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36961. /**
  36962. * Clones the current emitter and returns a copy of it
  36963. * @returns the new emitter
  36964. */
  36965. clone(): BoxParticleEmitter;
  36966. /**
  36967. * Called by the GPUParticleSystem to setup the update shader
  36968. * @param effect defines the update shader
  36969. */
  36970. applyToShader(effect: Effect): void;
  36971. /**
  36972. * Returns a string to use to update the GPU particles update shader
  36973. * @returns a string containng the defines string
  36974. */
  36975. getEffectDefines(): string;
  36976. /**
  36977. * Returns the string "BoxParticleEmitter"
  36978. * @returns a string containing the class name
  36979. */
  36980. getClassName(): string;
  36981. /**
  36982. * Serializes the particle system to a JSON object.
  36983. * @returns the JSON object
  36984. */
  36985. serialize(): any;
  36986. /**
  36987. * Parse properties from a JSON object
  36988. * @param serializationObject defines the JSON object
  36989. */
  36990. parse(serializationObject: any): void;
  36991. }
  36992. }
  36993. declare module BABYLON {
  36994. /**
  36995. * Particle emitter emitting particles from the inside of a cone.
  36996. * It emits the particles alongside the cone volume from the base to the particle.
  36997. * The emission direction might be randomized.
  36998. */
  36999. class ConeParticleEmitter implements IParticleEmitterType {
  37000. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  37001. directionRandomizer: number;
  37002. private _radius;
  37003. private _angle;
  37004. private _height;
  37005. /**
  37006. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  37007. */
  37008. radiusRange: number;
  37009. /**
  37010. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  37011. */
  37012. heightRange: number;
  37013. /**
  37014. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  37015. */
  37016. emitFromSpawnPointOnly: boolean;
  37017. /**
  37018. * Gets or sets the radius of the emission cone
  37019. */
  37020. radius: number;
  37021. /**
  37022. * Gets or sets the angle of the emission cone
  37023. */
  37024. angle: number;
  37025. private _buildHeight;
  37026. /**
  37027. * Creates a new instance ConeParticleEmitter
  37028. * @param radius the radius of the emission cone (1 by default)
  37029. * @param angles the cone base angle (PI by default)
  37030. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  37031. */
  37032. constructor(radius?: number, angle?: number,
  37033. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  37034. directionRandomizer?: number);
  37035. /**
  37036. * Called by the particle System when the direction is computed for the created particle.
  37037. * @param worldMatrix is the world matrix of the particle system
  37038. * @param directionToUpdate is the direction vector to update with the result
  37039. * @param particle is the particle we are computed the direction for
  37040. */
  37041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37042. /**
  37043. * Called by the particle System when the position is computed for the created particle.
  37044. * @param worldMatrix is the world matrix of the particle system
  37045. * @param positionToUpdate is the position vector to update with the result
  37046. * @param particle is the particle we are computed the position for
  37047. */
  37048. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37049. /**
  37050. * Clones the current emitter and returns a copy of it
  37051. * @returns the new emitter
  37052. */
  37053. clone(): ConeParticleEmitter;
  37054. /**
  37055. * Called by the GPUParticleSystem to setup the update shader
  37056. * @param effect defines the update shader
  37057. */
  37058. applyToShader(effect: Effect): void;
  37059. /**
  37060. * Returns a string to use to update the GPU particles update shader
  37061. * @returns a string containng the defines string
  37062. */
  37063. getEffectDefines(): string;
  37064. /**
  37065. * Returns the string "ConeParticleEmitter"
  37066. * @returns a string containing the class name
  37067. */
  37068. getClassName(): string;
  37069. /**
  37070. * Serializes the particle system to a JSON object.
  37071. * @returns the JSON object
  37072. */
  37073. serialize(): any;
  37074. /**
  37075. * Parse properties from a JSON object
  37076. * @param serializationObject defines the JSON object
  37077. */
  37078. parse(serializationObject: any): void;
  37079. }
  37080. }
  37081. declare module BABYLON {
  37082. /**
  37083. * Particle emitter emitting particles from the inside of a hemisphere.
  37084. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  37085. */
  37086. class HemisphericParticleEmitter implements IParticleEmitterType {
  37087. /**
  37088. * The radius of the emission hemisphere.
  37089. */
  37090. radius: number;
  37091. /**
  37092. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37093. */
  37094. radiusRange: number;
  37095. /**
  37096. * How much to randomize the particle direction [0-1].
  37097. */
  37098. directionRandomizer: number;
  37099. /**
  37100. * Creates a new instance HemisphericParticleEmitter
  37101. * @param radius the radius of the emission hemisphere (1 by default)
  37102. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  37103. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  37104. */
  37105. constructor(
  37106. /**
  37107. * The radius of the emission hemisphere.
  37108. */
  37109. radius?: number,
  37110. /**
  37111. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37112. */
  37113. radiusRange?: number,
  37114. /**
  37115. * How much to randomize the particle direction [0-1].
  37116. */
  37117. directionRandomizer?: number);
  37118. /**
  37119. * Called by the particle System when the direction is computed for the created particle.
  37120. * @param worldMatrix is the world matrix of the particle system
  37121. * @param directionToUpdate is the direction vector to update with the result
  37122. * @param particle is the particle we are computed the direction for
  37123. */
  37124. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37125. /**
  37126. * Called by the particle System when the position is computed for the created particle.
  37127. * @param worldMatrix is the world matrix of the particle system
  37128. * @param positionToUpdate is the position vector to update with the result
  37129. * @param particle is the particle we are computed the position for
  37130. */
  37131. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37132. /**
  37133. * Clones the current emitter and returns a copy of it
  37134. * @returns the new emitter
  37135. */
  37136. clone(): HemisphericParticleEmitter;
  37137. /**
  37138. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37139. * @param effect defines the update shader
  37140. */
  37141. applyToShader(effect: Effect): void;
  37142. /**
  37143. * Returns a string to use to update the GPU particles update shader
  37144. * @returns a string containng the defines string
  37145. */
  37146. getEffectDefines(): string;
  37147. /**
  37148. * Returns the string "HemisphericParticleEmitter"
  37149. * @returns a string containing the class name
  37150. */
  37151. getClassName(): string;
  37152. /**
  37153. * Serializes the particle system to a JSON object.
  37154. * @returns the JSON object
  37155. */
  37156. serialize(): any;
  37157. /**
  37158. * Parse properties from a JSON object
  37159. * @param serializationObject defines the JSON object
  37160. */
  37161. parse(serializationObject: any): void;
  37162. }
  37163. }
  37164. declare module BABYLON {
  37165. /**
  37166. * Particle emitter represents a volume emitting particles.
  37167. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  37168. */
  37169. interface IParticleEmitterType {
  37170. /**
  37171. * Called by the particle System when the direction is computed for the created particle.
  37172. * @param worldMatrix is the world matrix of the particle system
  37173. * @param directionToUpdate is the direction vector to update with the result
  37174. * @param particle is the particle we are computed the direction for
  37175. */
  37176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37177. /**
  37178. * Called by the particle System when the position is computed for the created particle.
  37179. * @param worldMatrix is the world matrix of the particle system
  37180. * @param positionToUpdate is the position vector to update with the result
  37181. * @param particle is the particle we are computed the position for
  37182. */
  37183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37184. /**
  37185. * Clones the current emitter and returns a copy of it
  37186. * @returns the new emitter
  37187. */
  37188. clone(): IParticleEmitterType;
  37189. /**
  37190. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37191. * @param effect defines the update shader
  37192. */
  37193. applyToShader(effect: Effect): void;
  37194. /**
  37195. * Returns a string to use to update the GPU particles update shader
  37196. * @returns the effect defines string
  37197. */
  37198. getEffectDefines(): string;
  37199. /**
  37200. * Returns a string representing the class name
  37201. * @returns a string containing the class name
  37202. */
  37203. getClassName(): string;
  37204. /**
  37205. * Serializes the particle system to a JSON object.
  37206. * @returns the JSON object
  37207. */
  37208. serialize(): any;
  37209. /**
  37210. * Parse properties from a JSON object
  37211. * @param serializationObject defines the JSON object
  37212. */
  37213. parse(serializationObject: any): void;
  37214. }
  37215. }
  37216. declare module BABYLON {
  37217. /**
  37218. * Particle emitter emitting particles from a point.
  37219. * It emits the particles randomly between 2 given directions.
  37220. */
  37221. class PointParticleEmitter implements IParticleEmitterType {
  37222. /**
  37223. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37224. */
  37225. direction1: Vector3;
  37226. /**
  37227. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37228. */
  37229. direction2: Vector3;
  37230. /**
  37231. * Creates a new instance PointParticleEmitter
  37232. */
  37233. constructor();
  37234. /**
  37235. * Called by the particle System when the direction is computed for the created particle.
  37236. * @param worldMatrix is the world matrix of the particle system
  37237. * @param directionToUpdate is the direction vector to update with the result
  37238. * @param particle is the particle we are computed the direction for
  37239. */
  37240. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37241. /**
  37242. * Called by the particle System when the position is computed for the created particle.
  37243. * @param worldMatrix is the world matrix of the particle system
  37244. * @param positionToUpdate is the position vector to update with the result
  37245. * @param particle is the particle we are computed the position for
  37246. */
  37247. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37248. /**
  37249. * Clones the current emitter and returns a copy of it
  37250. * @returns the new emitter
  37251. */
  37252. clone(): PointParticleEmitter;
  37253. /**
  37254. * Called by the GPUParticleSystem to setup the update shader
  37255. * @param effect defines the update shader
  37256. */
  37257. applyToShader(effect: Effect): void;
  37258. /**
  37259. * Returns a string to use to update the GPU particles update shader
  37260. * @returns a string containng the defines string
  37261. */
  37262. getEffectDefines(): string;
  37263. /**
  37264. * Returns the string "PointParticleEmitter"
  37265. * @returns a string containing the class name
  37266. */
  37267. getClassName(): string;
  37268. /**
  37269. * Serializes the particle system to a JSON object.
  37270. * @returns the JSON object
  37271. */
  37272. serialize(): any;
  37273. /**
  37274. * Parse properties from a JSON object
  37275. * @param serializationObject defines the JSON object
  37276. */
  37277. parse(serializationObject: any): void;
  37278. }
  37279. }
  37280. declare module BABYLON {
  37281. /**
  37282. * Particle emitter emitting particles from the inside of a sphere.
  37283. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  37284. */
  37285. class SphereParticleEmitter implements IParticleEmitterType {
  37286. /**
  37287. * The radius of the emission sphere.
  37288. */
  37289. radius: number;
  37290. /**
  37291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37292. */
  37293. radiusRange: number;
  37294. /**
  37295. * How much to randomize the particle direction [0-1].
  37296. */
  37297. directionRandomizer: number;
  37298. /**
  37299. * Creates a new instance SphereParticleEmitter
  37300. * @param radius the radius of the emission sphere (1 by default)
  37301. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  37302. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  37303. */
  37304. constructor(
  37305. /**
  37306. * The radius of the emission sphere.
  37307. */
  37308. radius?: number,
  37309. /**
  37310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37311. */
  37312. radiusRange?: number,
  37313. /**
  37314. * How much to randomize the particle direction [0-1].
  37315. */
  37316. directionRandomizer?: number);
  37317. /**
  37318. * Called by the particle System when the direction is computed for the created particle.
  37319. * @param worldMatrix is the world matrix of the particle system
  37320. * @param directionToUpdate is the direction vector to update with the result
  37321. * @param particle is the particle we are computed the direction for
  37322. */
  37323. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37324. /**
  37325. * Called by the particle System when the position is computed for the created particle.
  37326. * @param worldMatrix is the world matrix of the particle system
  37327. * @param positionToUpdate is the position vector to update with the result
  37328. * @param particle is the particle we are computed the position for
  37329. */
  37330. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37331. /**
  37332. * Clones the current emitter and returns a copy of it
  37333. * @returns the new emitter
  37334. */
  37335. clone(): SphereParticleEmitter;
  37336. /**
  37337. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37338. * @param effect defines the update shader
  37339. */
  37340. applyToShader(effect: Effect): void;
  37341. /**
  37342. * Returns a string to use to update the GPU particles update shader
  37343. * @returns a string containng the defines string
  37344. */
  37345. getEffectDefines(): string;
  37346. /**
  37347. * Returns the string "SphereParticleEmitter"
  37348. * @returns a string containing the class name
  37349. */
  37350. getClassName(): string;
  37351. /**
  37352. * Serializes the particle system to a JSON object.
  37353. * @returns the JSON object
  37354. */
  37355. serialize(): any;
  37356. /**
  37357. * Parse properties from a JSON object
  37358. * @param serializationObject defines the JSON object
  37359. */
  37360. parse(serializationObject: any): void;
  37361. }
  37362. /**
  37363. * Particle emitter emitting particles from the inside of a sphere.
  37364. * It emits the particles randomly between two vectors.
  37365. */
  37366. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  37367. /**
  37368. * The min limit of the emission direction.
  37369. */
  37370. direction1: Vector3;
  37371. /**
  37372. * The max limit of the emission direction.
  37373. */
  37374. direction2: Vector3;
  37375. /**
  37376. * Creates a new instance SphereDirectedParticleEmitter
  37377. * @param radius the radius of the emission sphere (1 by default)
  37378. * @param direction1 the min limit of the emission direction (up vector by default)
  37379. * @param direction2 the max limit of the emission direction (up vector by default)
  37380. */
  37381. constructor(radius?: number,
  37382. /**
  37383. * The min limit of the emission direction.
  37384. */
  37385. direction1?: Vector3,
  37386. /**
  37387. * The max limit of the emission direction.
  37388. */
  37389. direction2?: Vector3);
  37390. /**
  37391. * Called by the particle System when the direction is computed for the created particle.
  37392. * @param worldMatrix is the world matrix of the particle system
  37393. * @param directionToUpdate is the direction vector to update with the result
  37394. * @param particle is the particle we are computed the direction for
  37395. */
  37396. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37397. /**
  37398. * Clones the current emitter and returns a copy of it
  37399. * @returns the new emitter
  37400. */
  37401. clone(): SphereDirectedParticleEmitter;
  37402. /**
  37403. * Called by the GPUParticleSystem to setup the update shader
  37404. * @param effect defines the update shader
  37405. */
  37406. applyToShader(effect: Effect): void;
  37407. /**
  37408. * Returns a string to use to update the GPU particles update shader
  37409. * @returns a string containng the defines string
  37410. */
  37411. getEffectDefines(): string;
  37412. /**
  37413. * Returns the string "SphereDirectedParticleEmitter"
  37414. * @returns a string containing the class name
  37415. */
  37416. getClassName(): string;
  37417. /**
  37418. * Serializes the particle system to a JSON object.
  37419. * @returns the JSON object
  37420. */
  37421. serialize(): any;
  37422. /**
  37423. * Parse properties from a JSON object
  37424. * @param serializationObject defines the JSON object
  37425. */
  37426. parse(serializationObject: any): void;
  37427. }
  37428. }
  37429. declare module BABYLON {
  37430. class CannonJSPlugin implements IPhysicsEnginePlugin {
  37431. private _useDeltaForWorldStep;
  37432. world: any;
  37433. name: string;
  37434. private _physicsMaterials;
  37435. private _fixedTimeStep;
  37436. BJSCANNON: any;
  37437. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  37438. setGravity(gravity: Vector3): void;
  37439. setTimeStep(timeStep: number): void;
  37440. getTimeStep(): number;
  37441. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  37442. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37443. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37444. generatePhysicsBody(impostor: PhysicsImpostor): void;
  37445. private _processChildMeshes;
  37446. removePhysicsBody(impostor: PhysicsImpostor): void;
  37447. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  37448. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  37449. private _addMaterial;
  37450. private _checkWithEpsilon;
  37451. private _createShape;
  37452. private _createHeightmap;
  37453. private _minus90X;
  37454. private _plus90X;
  37455. private _tmpPosition;
  37456. private _tmpDeltaPosition;
  37457. private _tmpUnityRotation;
  37458. private _updatePhysicsBodyTransformation;
  37459. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  37460. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  37461. isSupported(): boolean;
  37462. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37463. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37464. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37465. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37466. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  37467. getBodyMass(impostor: PhysicsImpostor): number;
  37468. getBodyFriction(impostor: PhysicsImpostor): number;
  37469. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  37470. getBodyRestitution(impostor: PhysicsImpostor): number;
  37471. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  37472. sleepBody(impostor: PhysicsImpostor): void;
  37473. wakeUpBody(impostor: PhysicsImpostor): void;
  37474. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  37475. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  37476. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  37477. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  37478. getRadius(impostor: PhysicsImpostor): number;
  37479. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  37480. dispose(): void;
  37481. private _extendNamespace;
  37482. }
  37483. }
  37484. declare module BABYLON {
  37485. class OimoJSPlugin implements IPhysicsEnginePlugin {
  37486. world: any;
  37487. name: string;
  37488. BJSOIMO: any;
  37489. constructor(iterations?: number);
  37490. setGravity(gravity: Vector3): void;
  37491. setTimeStep(timeStep: number): void;
  37492. getTimeStep(): number;
  37493. private _tmpImpostorsArray;
  37494. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  37495. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37496. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37497. generatePhysicsBody(impostor: PhysicsImpostor): void;
  37498. private _tmpPositionVector;
  37499. removePhysicsBody(impostor: PhysicsImpostor): void;
  37500. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  37501. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  37502. isSupported(): boolean;
  37503. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  37504. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  37505. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37506. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37507. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37508. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37509. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  37510. getBodyMass(impostor: PhysicsImpostor): number;
  37511. getBodyFriction(impostor: PhysicsImpostor): number;
  37512. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  37513. getBodyRestitution(impostor: PhysicsImpostor): number;
  37514. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  37515. sleepBody(impostor: PhysicsImpostor): void;
  37516. wakeUpBody(impostor: PhysicsImpostor): void;
  37517. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  37518. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  37519. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  37520. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  37521. getRadius(impostor: PhysicsImpostor): number;
  37522. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  37523. dispose(): void;
  37524. }
  37525. }
  37526. declare module BABYLON {
  37527. /**
  37528. * This represents a set of one or more post processes in Babylon.
  37529. * A post process can be used to apply a shader to a texture after it is rendered.
  37530. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  37531. */
  37532. class PostProcessRenderEffect {
  37533. private _postProcesses;
  37534. private _getPostProcesses;
  37535. private _singleInstance;
  37536. private _cameras;
  37537. private _indicesForCamera;
  37538. /**
  37539. * Name of the effect
  37540. */
  37541. _name: string;
  37542. /**
  37543. * Instantiates a post process render effect.
  37544. * A post process can be used to apply a shader to a texture after it is rendered.
  37545. * @param engine The engine the effect is tied to
  37546. * @param name The name of the effect
  37547. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  37548. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  37549. */
  37550. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  37551. /**
  37552. * Checks if all the post processes in the effect are supported.
  37553. */
  37554. readonly isSupported: boolean;
  37555. /**
  37556. * Updates the current state of the effect
  37557. */
  37558. _update(): void;
  37559. /**
  37560. * Attaches the effect on cameras
  37561. * @param cameras The camera to attach to.
  37562. */
  37563. _attachCameras(cameras: Camera): void;
  37564. /**
  37565. * Attaches the effect on cameras
  37566. * @param cameras The camera to attach to.
  37567. */
  37568. _attachCameras(cameras: Camera[]): void;
  37569. /**
  37570. * Detatches the effect on cameras
  37571. * @param cameras The camera to detatch from.
  37572. */
  37573. _detachCameras(cameras: Camera): void;
  37574. /**
  37575. * Detatches the effect on cameras
  37576. * @param cameras The camera to detatch from.
  37577. */
  37578. _detachCameras(cameras: Camera[]): void;
  37579. /**
  37580. * Enables the effect on given cameras
  37581. * @param cameras The camera to enable.
  37582. */
  37583. _enable(cameras: Camera): void;
  37584. /**
  37585. * Enables the effect on given cameras
  37586. * @param cameras The camera to enable.
  37587. */
  37588. _enable(cameras: Nullable<Camera[]>): void;
  37589. /**
  37590. * Disables the effect on the given cameras
  37591. * @param cameras The camera to disable.
  37592. */
  37593. _disable(cameras: Camera): void;
  37594. /**
  37595. * Disables the effect on the given cameras
  37596. * @param cameras The camera to disable.
  37597. */
  37598. _disable(cameras: Nullable<Camera[]>): void;
  37599. /**
  37600. * Gets a list of the post processes contained in the effect.
  37601. * @param camera The camera to get the post processes on.
  37602. * @returns The list of the post processes in the effect.
  37603. */
  37604. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  37605. }
  37606. }
  37607. declare module BABYLON {
  37608. class PostProcessRenderPipeline {
  37609. private engine;
  37610. private _renderEffects;
  37611. private _renderEffectsForIsolatedPass;
  37612. protected _cameras: Camera[];
  37613. _name: string;
  37614. constructor(engine: Engine, name: string);
  37615. getClassName(): string;
  37616. readonly isSupported: boolean;
  37617. addEffect(renderEffect: PostProcessRenderEffect): void;
  37618. _rebuild(): void;
  37619. _enableEffect(renderEffectName: string, cameras: Camera): void;
  37620. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  37621. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  37622. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  37623. _attachCameras(cameras: Camera, unique: boolean): void;
  37624. _attachCameras(cameras: Camera[], unique: boolean): void;
  37625. _detachCameras(cameras: Camera): void;
  37626. _detachCameras(cameras: Nullable<Camera[]>): void;
  37627. _update(): void;
  37628. _reset(): void;
  37629. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  37630. dispose(): void;
  37631. }
  37632. }
  37633. declare module BABYLON {
  37634. class PostProcessRenderPipelineManager {
  37635. private _renderPipelines;
  37636. constructor();
  37637. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  37638. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  37639. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  37640. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  37641. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  37642. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  37643. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  37644. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  37645. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  37646. update(): void;
  37647. _rebuild(): void;
  37648. dispose(): void;
  37649. }
  37650. }
  37651. declare module BABYLON {
  37652. /**
  37653. * Helper class dealing with the extraction of spherical polynomial dataArray
  37654. * from a cube map.
  37655. */
  37656. class CubeMapToSphericalPolynomialTools {
  37657. private static FileFaces;
  37658. /**
  37659. * Converts a texture to the according Spherical Polynomial data.
  37660. * This extracts the first 3 orders only as they are the only one used in the lighting.
  37661. *
  37662. * @param texture The texture to extract the information from.
  37663. * @return The Spherical Polynomial data.
  37664. */
  37665. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  37666. /**
  37667. * Converts a cubemap to the according Spherical Polynomial data.
  37668. * This extracts the first 3 orders only as they are the only one used in the lighting.
  37669. *
  37670. * @param cubeInfo The Cube map to extract the information from.
  37671. * @return The Spherical Polynomial data.
  37672. */
  37673. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  37674. }
  37675. }
  37676. declare module BABYLON {
  37677. /**
  37678. * Header information of HDR texture files.
  37679. */
  37680. interface HDRInfo {
  37681. /**
  37682. * The height of the texture in pixels.
  37683. */
  37684. height: number;
  37685. /**
  37686. * The width of the texture in pixels.
  37687. */
  37688. width: number;
  37689. /**
  37690. * The index of the beginning of the data in the binary file.
  37691. */
  37692. dataPosition: number;
  37693. }
  37694. /**
  37695. * This groups tools to convert HDR texture to native colors array.
  37696. */
  37697. class HDRTools {
  37698. private static Ldexp;
  37699. private static Rgbe2float;
  37700. private static readStringLine;
  37701. /**
  37702. * Reads header information from an RGBE texture stored in a native array.
  37703. * More information on this format are available here:
  37704. * https://en.wikipedia.org/wiki/RGBE_image_format
  37705. *
  37706. * @param uint8array The binary file stored in native array.
  37707. * @return The header information.
  37708. */
  37709. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  37710. /**
  37711. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  37712. * This RGBE texture needs to store the information as a panorama.
  37713. *
  37714. * More information on this format are available here:
  37715. * https://en.wikipedia.org/wiki/RGBE_image_format
  37716. *
  37717. * @param buffer The binary file stored in an array buffer.
  37718. * @param size The expected size of the extracted cubemap.
  37719. * @return The Cube Map information.
  37720. */
  37721. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  37722. /**
  37723. * Returns the pixels data extracted from an RGBE texture.
  37724. * This pixels will be stored left to right up to down in the R G B order in one array.
  37725. *
  37726. * More information on this format are available here:
  37727. * https://en.wikipedia.org/wiki/RGBE_image_format
  37728. *
  37729. * @param uint8array The binary file stored in an array buffer.
  37730. * @param hdrInfo The header information of the file.
  37731. * @return The pixels data in RGB right to left up to down order.
  37732. */
  37733. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  37734. private static RGBE_ReadPixels_RLE;
  37735. }
  37736. }
  37737. declare module BABYLON {
  37738. /**
  37739. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  37740. */
  37741. interface CubeMapInfo {
  37742. /**
  37743. * The pixel array for the front face.
  37744. * This is stored in format, left to right, up to down format.
  37745. */
  37746. front: Nullable<ArrayBufferView>;
  37747. /**
  37748. * The pixel array for the back face.
  37749. * This is stored in format, left to right, up to down format.
  37750. */
  37751. back: Nullable<ArrayBufferView>;
  37752. /**
  37753. * The pixel array for the left face.
  37754. * This is stored in format, left to right, up to down format.
  37755. */
  37756. left: Nullable<ArrayBufferView>;
  37757. /**
  37758. * The pixel array for the right face.
  37759. * This is stored in format, left to right, up to down format.
  37760. */
  37761. right: Nullable<ArrayBufferView>;
  37762. /**
  37763. * The pixel array for the up face.
  37764. * This is stored in format, left to right, up to down format.
  37765. */
  37766. up: Nullable<ArrayBufferView>;
  37767. /**
  37768. * The pixel array for the down face.
  37769. * This is stored in format, left to right, up to down format.
  37770. */
  37771. down: Nullable<ArrayBufferView>;
  37772. /**
  37773. * The size of the cubemap stored.
  37774. *
  37775. * Each faces will be size * size pixels.
  37776. */
  37777. size: number;
  37778. /**
  37779. * The format of the texture.
  37780. *
  37781. * RGBA, RGB.
  37782. */
  37783. format: number;
  37784. /**
  37785. * The type of the texture data.
  37786. *
  37787. * UNSIGNED_INT, FLOAT.
  37788. */
  37789. type: number;
  37790. /**
  37791. * Specifies whether the texture is in gamma space.
  37792. */
  37793. gammaSpace: boolean;
  37794. }
  37795. /**
  37796. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  37797. */
  37798. class PanoramaToCubeMapTools {
  37799. private static FACE_FRONT;
  37800. private static FACE_BACK;
  37801. private static FACE_RIGHT;
  37802. private static FACE_LEFT;
  37803. private static FACE_DOWN;
  37804. private static FACE_UP;
  37805. /**
  37806. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  37807. *
  37808. * @param float32Array The source data.
  37809. * @param inputWidth The width of the input panorama.
  37810. * @param inputhHeight The height of the input panorama.
  37811. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  37812. * @return The cubemap data
  37813. */
  37814. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  37815. private static CreateCubemapTexture;
  37816. private static CalcProjectionSpherical;
  37817. }
  37818. }
  37819. declare module BABYLON {
  37820. }
  37821. declare module BABYLON {
  37822. }
  37823. declare module BABYLON {
  37824. }
  37825. declare module BABYLON {
  37826. }
  37827. declare module BABYLON {
  37828. class CustomProceduralTexture extends ProceduralTexture {
  37829. private _animate;
  37830. private _time;
  37831. private _config;
  37832. private _texturePath;
  37833. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  37834. private loadJson;
  37835. isReady(): boolean;
  37836. render(useCameraPostProcess?: boolean): void;
  37837. updateTextures(): void;
  37838. updateShaderUniforms(): void;
  37839. animate: boolean;
  37840. }
  37841. }
  37842. declare module BABYLON {
  37843. /**
  37844. * Class used to generate noise procedural textures
  37845. */
  37846. class NoiseProceduralTexture extends ProceduralTexture {
  37847. private _time;
  37848. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  37849. brightness: number;
  37850. /** Defines the number of octaves to process */
  37851. octaves: number;
  37852. /** Defines the level of persistence (0.8 by default) */
  37853. persistence: number;
  37854. /** Gets or sets animation speed factor (default is 1) */
  37855. animationSpeedFactor: number;
  37856. /**
  37857. * Creates a new NoiseProceduralTexture
  37858. * @param name defines the name fo the texture
  37859. * @param size defines the size of the texture (default is 256)
  37860. * @param scene defines the hosting scene
  37861. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  37862. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  37863. */
  37864. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  37865. private _updateShaderUniforms;
  37866. /** Generate the current state of the procedural texture */
  37867. render(useCameraPostProcess?: boolean): void;
  37868. /**
  37869. * Serializes this noise procedural texture
  37870. * @returns a serialized noise procedural texture object
  37871. */
  37872. serialize(): any;
  37873. /**
  37874. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  37875. * @param parsedTexture defines parsed texture data
  37876. * @param scene defines the current scene
  37877. * @param rootUrl defines the root URL containing noise procedural texture information
  37878. * @returns a parsed NoiseProceduralTexture
  37879. */
  37880. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  37881. }
  37882. }
  37883. declare module BABYLON {
  37884. class ProceduralTexture extends Texture {
  37885. isCube: boolean;
  37886. private _size;
  37887. _generateMipMaps: boolean;
  37888. isEnabled: boolean;
  37889. private _currentRefreshId;
  37890. private _refreshRate;
  37891. onGenerated: () => void;
  37892. private _vertexBuffers;
  37893. private _indexBuffer;
  37894. private _effect;
  37895. private _uniforms;
  37896. private _samplers;
  37897. private _fragment;
  37898. _textures: {
  37899. [key: string]: Texture;
  37900. };
  37901. private _floats;
  37902. private _ints;
  37903. private _floatsArrays;
  37904. private _colors3;
  37905. private _colors4;
  37906. private _vectors2;
  37907. private _vectors3;
  37908. private _matrices;
  37909. private _fallbackTexture;
  37910. private _fallbackTextureUsed;
  37911. private _engine;
  37912. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  37913. private _createIndexBuffer;
  37914. _rebuild(): void;
  37915. reset(): void;
  37916. isReady(): boolean;
  37917. resetRefreshCounter(): void;
  37918. setFragment(fragment: any): void;
  37919. refreshRate: number;
  37920. _shouldRender(): boolean;
  37921. getRenderSize(): number;
  37922. resize(size: number, generateMipMaps: boolean): void;
  37923. private _checkUniform;
  37924. setTexture(name: string, texture: Texture): ProceduralTexture;
  37925. setFloat(name: string, value: number): ProceduralTexture;
  37926. /**
  37927. * Set the value of an uniform to an integer value
  37928. * @param name defines the name of the uniform
  37929. * @param value defines the value to set
  37930. * @returns the current procedural texture
  37931. */
  37932. setInt(name: string, value: number): ProceduralTexture;
  37933. setFloats(name: string, value: number[]): ProceduralTexture;
  37934. setColor3(name: string, value: Color3): ProceduralTexture;
  37935. setColor4(name: string, value: Color4): ProceduralTexture;
  37936. setVector2(name: string, value: Vector2): ProceduralTexture;
  37937. setVector3(name: string, value: Vector3): ProceduralTexture;
  37938. setMatrix(name: string, value: Matrix): ProceduralTexture;
  37939. render(useCameraPostProcess?: boolean): void;
  37940. clone(): ProceduralTexture;
  37941. dispose(): void;
  37942. }
  37943. }
  37944. declare module BABYLON {
  37945. /**
  37946. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  37947. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  37948. */
  37949. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  37950. private _scene;
  37951. private _camerasToBeAttached;
  37952. /**
  37953. * ID of the sharpen post process,
  37954. */
  37955. private readonly SharpenPostProcessId;
  37956. /**
  37957. * ID of the image processing post process;
  37958. */
  37959. readonly ImageProcessingPostProcessId: string;
  37960. /**
  37961. * ID of the Fast Approximate Anti-Aliasing post process;
  37962. */
  37963. readonly FxaaPostProcessId: string;
  37964. /**
  37965. * ID of the chromatic aberration post process,
  37966. */
  37967. private readonly ChromaticAberrationPostProcessId;
  37968. /**
  37969. * ID of the grain post process
  37970. */
  37971. private readonly GrainPostProcessId;
  37972. /**
  37973. * Sharpen post process which will apply a sharpen convolution to enhance edges
  37974. */
  37975. sharpen: SharpenPostProcess;
  37976. private _sharpenEffect;
  37977. private bloom;
  37978. /**
  37979. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  37980. */
  37981. depthOfField: DepthOfFieldEffect;
  37982. /**
  37983. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  37984. */
  37985. fxaa: FxaaPostProcess;
  37986. /**
  37987. * Image post processing pass used to perform operations such as tone mapping or color grading.
  37988. */
  37989. imageProcessing: ImageProcessingPostProcess;
  37990. /**
  37991. * Chromatic aberration post process which will shift rgb colors in the image
  37992. */
  37993. chromaticAberration: ChromaticAberrationPostProcess;
  37994. private _chromaticAberrationEffect;
  37995. /**
  37996. * Grain post process which add noise to the image
  37997. */
  37998. grain: GrainPostProcess;
  37999. private _grainEffect;
  38000. /**
  38001. * Glow post process which adds a glow to emmisive areas of the image
  38002. */
  38003. private _glowLayer;
  38004. /**
  38005. * Animations which can be used to tweak settings over a period of time
  38006. */
  38007. animations: Animation[];
  38008. private _imageProcessingConfigurationObserver;
  38009. private _sharpenEnabled;
  38010. private _bloomEnabled;
  38011. private _depthOfFieldEnabled;
  38012. private _depthOfFieldBlurLevel;
  38013. private _fxaaEnabled;
  38014. private _imageProcessingEnabled;
  38015. private _defaultPipelineTextureType;
  38016. private _bloomScale;
  38017. private _chromaticAberrationEnabled;
  38018. private _grainEnabled;
  38019. private _buildAllowed;
  38020. /**
  38021. * Enable or disable the sharpen process from the pipeline
  38022. */
  38023. sharpenEnabled: boolean;
  38024. private _resizeObserver;
  38025. private _hardwareScaleLevel;
  38026. private _bloomKernel;
  38027. /**
  38028. * Specifies the size of the bloom blur kernel, relative to the final output size
  38029. */
  38030. bloomKernel: number;
  38031. /**
  38032. * Specifies the weight of the bloom in the final rendering
  38033. */
  38034. private _bloomWeight;
  38035. /**
  38036. * Specifies the luma threshold for the area that will be blurred by the bloom
  38037. */
  38038. private _bloomThreshold;
  38039. private _hdr;
  38040. /**
  38041. * The strength of the bloom.
  38042. */
  38043. bloomWeight: number;
  38044. /**
  38045. * The strength of the bloom.
  38046. */
  38047. bloomThreshold: number;
  38048. /**
  38049. * The scale of the bloom, lower value will provide better performance.
  38050. */
  38051. bloomScale: number;
  38052. /**
  38053. * Enable or disable the bloom from the pipeline
  38054. */
  38055. bloomEnabled: boolean;
  38056. private _rebuildBloom;
  38057. /**
  38058. * If the depth of field is enabled.
  38059. */
  38060. depthOfFieldEnabled: boolean;
  38061. /**
  38062. * Blur level of the depth of field effect. (Higher blur will effect performance)
  38063. */
  38064. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  38065. /**
  38066. * If the anti aliasing is enabled.
  38067. */
  38068. fxaaEnabled: boolean;
  38069. private _samples;
  38070. /**
  38071. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  38072. */
  38073. samples: number;
  38074. /**
  38075. * If image processing is enabled.
  38076. */
  38077. imageProcessingEnabled: boolean;
  38078. /**
  38079. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  38080. */
  38081. glowLayerEnabled: boolean;
  38082. /**
  38083. * Enable or disable the chromaticAberration process from the pipeline
  38084. */
  38085. chromaticAberrationEnabled: boolean;
  38086. /**
  38087. * Enable or disable the grain process from the pipeline
  38088. */
  38089. grainEnabled: boolean;
  38090. /**
  38091. * @constructor
  38092. * @param {string} name - The rendering pipeline name (default: "")
  38093. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  38094. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  38095. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  38096. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  38097. */
  38098. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  38099. /**
  38100. * Force the compilation of the entire pipeline.
  38101. */
  38102. prepare(): void;
  38103. private _hasCleared;
  38104. private _prevPostProcess;
  38105. private _prevPrevPostProcess;
  38106. private _setAutoClearAndTextureSharing;
  38107. private _buildPipeline;
  38108. private _disposePostProcesses;
  38109. /**
  38110. * Adds a camera to the pipeline
  38111. * @param camera the camera to be added
  38112. */
  38113. addCamera(camera: Camera): void;
  38114. /**
  38115. * Removes a camera from the pipeline
  38116. * @param camera the camera to remove
  38117. */
  38118. removeCamera(camera: Camera): void;
  38119. /**
  38120. * Dispose of the pipeline and stop all post processes
  38121. */
  38122. dispose(): void;
  38123. /**
  38124. * Serialize the rendering pipeline (Used when exporting)
  38125. * @returns the serialized object
  38126. */
  38127. serialize(): any;
  38128. /**
  38129. * Parse the serialized pipeline
  38130. * @param source Source pipeline.
  38131. * @param scene The scene to load the pipeline to.
  38132. * @param rootUrl The URL of the serialized pipeline.
  38133. * @returns An instantiated pipeline from the serialized object.
  38134. */
  38135. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  38136. }
  38137. }
  38138. declare module BABYLON {
  38139. class LensRenderingPipeline extends PostProcessRenderPipeline {
  38140. /**
  38141. * The chromatic aberration PostProcess id in the pipeline
  38142. */
  38143. LensChromaticAberrationEffect: string;
  38144. /**
  38145. * The highlights enhancing PostProcess id in the pipeline
  38146. */
  38147. HighlightsEnhancingEffect: string;
  38148. /**
  38149. * The depth-of-field PostProcess id in the pipeline
  38150. */
  38151. LensDepthOfFieldEffect: string;
  38152. private _scene;
  38153. private _depthTexture;
  38154. private _grainTexture;
  38155. private _chromaticAberrationPostProcess;
  38156. private _highlightsPostProcess;
  38157. private _depthOfFieldPostProcess;
  38158. private _edgeBlur;
  38159. private _grainAmount;
  38160. private _chromaticAberration;
  38161. private _distortion;
  38162. private _highlightsGain;
  38163. private _highlightsThreshold;
  38164. private _dofDistance;
  38165. private _dofAperture;
  38166. private _dofDarken;
  38167. private _dofPentagon;
  38168. private _blurNoise;
  38169. /**
  38170. * @constructor
  38171. *
  38172. * Effect parameters are as follow:
  38173. * {
  38174. * chromatic_aberration: number; // from 0 to x (1 for realism)
  38175. * edge_blur: number; // from 0 to x (1 for realism)
  38176. * distortion: number; // from 0 to x (1 for realism)
  38177. * grain_amount: number; // from 0 to 1
  38178. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  38179. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  38180. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  38181. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  38182. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  38183. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  38184. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  38185. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  38186. * }
  38187. * Note: if an effect parameter is unset, effect is disabled
  38188. *
  38189. * @param {string} name - The rendering pipeline name
  38190. * @param {object} parameters - An object containing all parameters (see above)
  38191. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38192. * @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)
  38193. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38194. */
  38195. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  38196. setEdgeBlur(amount: number): void;
  38197. disableEdgeBlur(): void;
  38198. setGrainAmount(amount: number): void;
  38199. disableGrain(): void;
  38200. setChromaticAberration(amount: number): void;
  38201. disableChromaticAberration(): void;
  38202. setEdgeDistortion(amount: number): void;
  38203. disableEdgeDistortion(): void;
  38204. setFocusDistance(amount: number): void;
  38205. disableDepthOfField(): void;
  38206. setAperture(amount: number): void;
  38207. setDarkenOutOfFocus(amount: number): void;
  38208. enablePentagonBokeh(): void;
  38209. disablePentagonBokeh(): void;
  38210. enableNoiseBlur(): void;
  38211. disableNoiseBlur(): void;
  38212. setHighlightsGain(amount: number): void;
  38213. setHighlightsThreshold(amount: number): void;
  38214. disableHighlights(): void;
  38215. /**
  38216. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  38217. */
  38218. dispose(disableDepthRender?: boolean): void;
  38219. private _createChromaticAberrationPostProcess;
  38220. private _createHighlightsPostProcess;
  38221. private _createDepthOfFieldPostProcess;
  38222. private _createGrainTexture;
  38223. }
  38224. }
  38225. declare module BABYLON {
  38226. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  38227. /**
  38228. * The PassPostProcess id in the pipeline that contains the original scene color
  38229. */
  38230. SSAOOriginalSceneColorEffect: string;
  38231. /**
  38232. * The SSAO PostProcess id in the pipeline
  38233. */
  38234. SSAORenderEffect: string;
  38235. /**
  38236. * The horizontal blur PostProcess id in the pipeline
  38237. */
  38238. SSAOBlurHRenderEffect: string;
  38239. /**
  38240. * The vertical blur PostProcess id in the pipeline
  38241. */
  38242. SSAOBlurVRenderEffect: string;
  38243. /**
  38244. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  38245. */
  38246. SSAOCombineRenderEffect: string;
  38247. /**
  38248. * The output strength of the SSAO post-process. Default value is 1.0.
  38249. */
  38250. totalStrength: number;
  38251. /**
  38252. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  38253. */
  38254. maxZ: number;
  38255. /**
  38256. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  38257. */
  38258. minZAspect: number;
  38259. /**
  38260. * Number of samples used for the SSAO calculations. Default value is 8
  38261. */
  38262. private _samples;
  38263. /**
  38264. * Ratio object used for SSAO ratio and blur ratio
  38265. */
  38266. private _ratio;
  38267. /**
  38268. * Dynamically generated sphere sampler.
  38269. */
  38270. private _sampleSphere;
  38271. /**
  38272. * Blur filter offsets
  38273. */
  38274. private _samplerOffsets;
  38275. samples: number;
  38276. /**
  38277. * Are we using bilateral blur ?
  38278. */
  38279. private _expensiveBlur;
  38280. expensiveBlur: boolean;
  38281. /**
  38282. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  38283. */
  38284. radius: number;
  38285. /**
  38286. * The base color of the SSAO post-process
  38287. * The final result is "base + ssao" between [0, 1]
  38288. */
  38289. base: number;
  38290. /**
  38291. * Support test.
  38292. */
  38293. static readonly IsSupported: boolean;
  38294. private _scene;
  38295. private _depthTexture;
  38296. private _normalTexture;
  38297. private _randomTexture;
  38298. private _originalColorPostProcess;
  38299. private _ssaoPostProcess;
  38300. private _blurHPostProcess;
  38301. private _blurVPostProcess;
  38302. private _ssaoCombinePostProcess;
  38303. private _firstUpdate;
  38304. /**
  38305. * @constructor
  38306. * @param {string} name - The rendering pipeline name
  38307. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38308. * @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 }
  38309. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38310. */
  38311. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  38312. /**
  38313. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  38314. */
  38315. dispose(disableGeometryBufferRenderer?: boolean): void;
  38316. private _createBlurPostProcess;
  38317. _rebuild(): void;
  38318. private _generateHemisphere;
  38319. private _createSSAOPostProcess;
  38320. private _createSSAOCombinePostProcess;
  38321. private _createRandomTexture;
  38322. /**
  38323. * Serialize the rendering pipeline (Used when exporting)
  38324. * @returns the serialized object
  38325. */
  38326. serialize(): any;
  38327. /**
  38328. * Parse the serialized pipeline
  38329. * @param source Source pipeline.
  38330. * @param scene The scene to load the pipeline to.
  38331. * @param rootUrl The URL of the serialized pipeline.
  38332. * @returns An instantiated pipeline from the serialized object.
  38333. */
  38334. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  38335. }
  38336. }
  38337. declare module BABYLON {
  38338. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  38339. /**
  38340. * The PassPostProcess id in the pipeline that contains the original scene color
  38341. */
  38342. SSAOOriginalSceneColorEffect: string;
  38343. /**
  38344. * The SSAO PostProcess id in the pipeline
  38345. */
  38346. SSAORenderEffect: string;
  38347. /**
  38348. * The horizontal blur PostProcess id in the pipeline
  38349. */
  38350. SSAOBlurHRenderEffect: string;
  38351. /**
  38352. * The vertical blur PostProcess id in the pipeline
  38353. */
  38354. SSAOBlurVRenderEffect: string;
  38355. /**
  38356. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  38357. */
  38358. SSAOCombineRenderEffect: string;
  38359. /**
  38360. * The output strength of the SSAO post-process. Default value is 1.0.
  38361. */
  38362. totalStrength: number;
  38363. /**
  38364. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  38365. */
  38366. radius: number;
  38367. /**
  38368. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  38369. * Must not be equal to fallOff and superior to fallOff.
  38370. * Default value is 0.975
  38371. */
  38372. area: number;
  38373. /**
  38374. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  38375. * Must not be equal to area and inferior to area.
  38376. * Default value is 0.0
  38377. */
  38378. fallOff: number;
  38379. /**
  38380. * The base color of the SSAO post-process
  38381. * The final result is "base + ssao" between [0, 1]
  38382. */
  38383. base: number;
  38384. private _scene;
  38385. private _depthTexture;
  38386. private _randomTexture;
  38387. private _originalColorPostProcess;
  38388. private _ssaoPostProcess;
  38389. private _blurHPostProcess;
  38390. private _blurVPostProcess;
  38391. private _ssaoCombinePostProcess;
  38392. private _firstUpdate;
  38393. /**
  38394. * @constructor
  38395. * @param {string} name - The rendering pipeline name
  38396. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38397. * @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 }
  38398. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38399. */
  38400. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  38401. /**
  38402. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  38403. */
  38404. dispose(disableDepthRender?: boolean): void;
  38405. private _createBlurPostProcess;
  38406. _rebuild(): void;
  38407. private _createSSAOPostProcess;
  38408. private _createSSAOCombinePostProcess;
  38409. private _createRandomTexture;
  38410. }
  38411. }
  38412. declare module BABYLON {
  38413. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  38414. /**
  38415. * Public members
  38416. */
  38417. originalPostProcess: Nullable<PostProcess>;
  38418. downSampleX4PostProcess: Nullable<PostProcess>;
  38419. brightPassPostProcess: Nullable<PostProcess>;
  38420. blurHPostProcesses: PostProcess[];
  38421. blurVPostProcesses: PostProcess[];
  38422. textureAdderPostProcess: Nullable<PostProcess>;
  38423. volumetricLightPostProcess: Nullable<PostProcess>;
  38424. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  38425. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  38426. volumetricLightMergePostProces: Nullable<PostProcess>;
  38427. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  38428. luminancePostProcess: Nullable<PostProcess>;
  38429. luminanceDownSamplePostProcesses: PostProcess[];
  38430. hdrPostProcess: Nullable<PostProcess>;
  38431. textureAdderFinalPostProcess: Nullable<PostProcess>;
  38432. lensFlareFinalPostProcess: Nullable<PostProcess>;
  38433. hdrFinalPostProcess: Nullable<PostProcess>;
  38434. lensFlarePostProcess: Nullable<PostProcess>;
  38435. lensFlareComposePostProcess: Nullable<PostProcess>;
  38436. motionBlurPostProcess: Nullable<PostProcess>;
  38437. depthOfFieldPostProcess: Nullable<PostProcess>;
  38438. brightThreshold: number;
  38439. blurWidth: number;
  38440. horizontalBlur: boolean;
  38441. exposure: number;
  38442. lensTexture: Nullable<Texture>;
  38443. volumetricLightCoefficient: number;
  38444. volumetricLightPower: number;
  38445. volumetricLightBlurScale: number;
  38446. sourceLight: Nullable<SpotLight | DirectionalLight>;
  38447. hdrMinimumLuminance: number;
  38448. hdrDecreaseRate: number;
  38449. hdrIncreaseRate: number;
  38450. lensColorTexture: Nullable<Texture>;
  38451. lensFlareStrength: number;
  38452. lensFlareGhostDispersal: number;
  38453. lensFlareHaloWidth: number;
  38454. lensFlareDistortionStrength: number;
  38455. lensStarTexture: Nullable<Texture>;
  38456. lensFlareDirtTexture: Nullable<Texture>;
  38457. depthOfFieldDistance: number;
  38458. depthOfFieldBlurWidth: number;
  38459. motionStrength: number;
  38460. animations: Animation[];
  38461. /**
  38462. * Private members
  38463. */
  38464. private _scene;
  38465. private _currentDepthOfFieldSource;
  38466. private _basePostProcess;
  38467. private _hdrCurrentLuminance;
  38468. private _floatTextureType;
  38469. private _ratio;
  38470. private _bloomEnabled;
  38471. private _depthOfFieldEnabled;
  38472. private _vlsEnabled;
  38473. private _lensFlareEnabled;
  38474. private _hdrEnabled;
  38475. private _motionBlurEnabled;
  38476. private _motionBlurSamples;
  38477. private _volumetricLightStepsCount;
  38478. BloomEnabled: boolean;
  38479. DepthOfFieldEnabled: boolean;
  38480. LensFlareEnabled: boolean;
  38481. HDREnabled: boolean;
  38482. VLSEnabled: boolean;
  38483. MotionBlurEnabled: boolean;
  38484. volumetricLightStepsCount: number;
  38485. motionBlurSamples: number;
  38486. /**
  38487. * @constructor
  38488. * @param {string} name - The rendering pipeline name
  38489. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38490. * @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)
  38491. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  38492. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38493. */
  38494. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  38495. private _buildPipeline;
  38496. private _createDownSampleX4PostProcess;
  38497. private _createBrightPassPostProcess;
  38498. private _createBlurPostProcesses;
  38499. private _createTextureAdderPostProcess;
  38500. private _createVolumetricLightPostProcess;
  38501. private _createLuminancePostProcesses;
  38502. private _createHdrPostProcess;
  38503. private _createLensFlarePostProcess;
  38504. private _createDepthOfFieldPostProcess;
  38505. private _createMotionBlurPostProcess;
  38506. private _getDepthTexture;
  38507. private _disposePostProcesses;
  38508. /**
  38509. * Dispose of the pipeline and stop all post processes
  38510. */
  38511. dispose(): void;
  38512. /**
  38513. * Serialize the rendering pipeline (Used when exporting)
  38514. * @returns the serialized object
  38515. */
  38516. serialize(): any;
  38517. /**
  38518. * Parse the serialized pipeline
  38519. * @param source Source pipeline.
  38520. * @param scene The scene to load the pipeline to.
  38521. * @param rootUrl The URL of the serialized pipeline.
  38522. * @returns An instantiated pipeline from the serialized object.
  38523. */
  38524. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  38525. static LuminanceSteps: number;
  38526. }
  38527. }